extras/abs-file.h
changeset 578 bff1af8455ca
parent 562 1e307df36810
child 654 c0ae01de361d
equal deleted inserted replaced
577:90a06832dcf3 578:bff1af8455ca
   116   if (MY_READ(&c, 1, 1, fp) != 1) {
   116   if (MY_READ(&c, 1, 1, fp) != 1) {
   117     return EOF;
   117     return EOF;
   118   }
   118   }
   119   return c;
   119   return c;
   120 }
   120 }
   121 static char * MY_GETS(char * const str, const int size,
   121 static char * MY_GETS(char * const str, const int size, 
   122 		      MY_FILETYPE *const fp) {
   122                       MY_FILETYPE *const fp) {
   123   int i = 0;
   123   int i = 0;
   124   int c;
   124   int c;
   125   do {
   125   do {
   126     if (i == size-1) {
   126     if (i == size-1) {
   127       break;
   127       break;
   129     c = MY_GETC(fp);
   129     c = MY_GETC(fp);
   130     if (c == EOF) {
   130     if (c == EOF) {
   131       break;
   131       break;
   132     }
   132     }
   133     str[i++] = c;
   133     str[i++] = c;
   134   } while (c != '\0' &&
   134   } while (c != '\0' && 
   135 	   c != -1 &&
   135       c != -1 && 
   136 	   c != '\n');
   136       c != '\n');
   137   str[i] = '\0';
   137   str[i] = '\0';
   138   if (i == 0) {
   138   if (i == 0) {
   139     return NULL;
   139     return NULL;
   140   }
   140   }
   141   return str;
   141   return str;