Magellan Linux

Diff of /trunk/mkinitrd-magellan/klibc/usr/dash/input.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1121 by niro, Fri Apr 24 18:32:46 2009 UTC revision 1122 by niro, Wed Aug 18 21:11:40 2010 UTC
# Line 53  Line 53 
53  #include "alias.h"  #include "alias.h"
54  #include "parser.h"  #include "parser.h"
55  #include "main.h"  #include "main.h"
56    #include "var.h"
57  #ifndef SMALL  #ifndef SMALL
58  #include "myhistedit.h"  #include "myhistedit.h"
59  #endif  #endif
# Line 107  EditLine *el; /* cookie for editline p Line 108  EditLine *el; /* cookie for editline p
108    
109  STATIC void pushfile(void);  STATIC void pushfile(void);
110  static int preadfd(void);  static int preadfd(void);
111    static void setinputfd(int fd, int push);
112    
113  #ifdef mkinit  #ifdef mkinit
114  INCLUDE <stdio.h>  INCLUDE <stdio.h>
# Line 125  RESET { Line 127  RESET {
127    
128    
129  /*  /*
  * Read a line from the script.  
  */  
   
 char *  
 pfgets(char *line, int len)  
 {  
  char *p = line;  
  int nleft = len;  
  int c;  
   
  while (--nleft > 0) {  
  c = pgetc2();  
  if (c == PEOF) {  
  if (p == line)  
  return NULL;  
  break;  
  }  
  *p++ = c;  
  if (c == '\n')  
  break;  
  }  
  *p = '\0';  
  return line;  
 }  
   
   
 /*  
130   * Read a character from the script, returning PEOF on end of file.   * Read a character from the script, returning PEOF on end of file.
131   * Nul characters in the input are silently discarded.   * Nul characters in the input are silently discarded.
132   */   */
# Line 436  setinputfile(const char *fname, int flag Line 411  setinputfile(const char *fname, int flag
411   sh_error("Can't open %s", fname);   sh_error("Can't open %s", fname);
412   }   }
413   if (fd < 10)   if (fd < 10)
414   fd = savefd(fd);   fd = savefd(fd, fd);
415   setinputfd(fd, flags & INPUT_PUSH_FILE);   setinputfd(fd, flags & INPUT_PUSH_FILE);
416  out:  out:
417   INTON;   INTON;
# Line 449  out: Line 424  out:
424   * interrupts off.   * interrupts off.
425   */   */
426    
427  void  static void
428  setinputfd(int fd, int push)  setinputfd(int fd, int push)
429  {  {
430   if (push) {   if (push) {
# Line 554  closescript(void) Line 529  closescript(void)
529   parsefile->fd = 0;   parsefile->fd = 0;
530   }   }
531  }  }
532    
533    
534    int lineno_inc(void)
535    {
536     int lineno = plinno++;
537    
538     setvarint("LINENO", lineno, 0);
539     return lineno;
540    }

Legend:
Removed from v.1121  
changed lines
  Added in v.1122