changeset 28773:9afdf8a67091

(PATH_LIST_SEPARATOR) [__MSDOS__ || WINDOWSNT]: Define to semi-colon. (FILENAME_EQ): New macro, for comparing file names. (add_member_decl, add_global_decl, add_member_defn): Use FILENAME_EQ. (process_file): Don't assume that fread always reads as many bytes as it was told to (DOS-style CR-LF text files fail this logic). (open_file): Allocate enough space for path->path plus the file name and the slash.
author Eli Zaretskii <eliz@gnu.org>
date Tue, 02 May 2000 11:01:29 +0000
parents 6d99cfcac023
children 6594b6dedae9
files lib-src/ebrowse.c
diffstat 1 files changed, 15 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/ebrowse.c	Tue May 02 10:40:37 2000 +0000
+++ b/lib-src/ebrowse.c	Tue May 02 11:01:29 2000 +0000
@@ -57,7 +57,13 @@
 
 /* The character used as a separator in path lists (like $PATH).  */
 
+#if defined(__MSDOS__) || defined(WINDOWSNT)
+#define PATH_LIST_SEPARATOR ';'
+#define FILENAME_EQ(X,Y)    (strcasecmp(X,Y) == 0)
+#else
 #define PATH_LIST_SEPARATOR ':'
+#define FILENAME_EQ(X,Y)    (streq(X,Y))
+#endif
 
 /* The default output file name.  */
 
@@ -749,7 +755,7 @@
     m = add_member (cls, name, var, sc, hash);
 
   /* Have we seen a new filename?  If so record that.  */
-  if (!cls->filename || !streq (cls->filename, filename))
+  if (!cls->filename || !FILENAME_EQ (cls->filename, filename))
     m->filename = filename;
 
   m->regexp = regexp;
@@ -820,7 +826,7 @@
   if (!cls->sfilename)
     cls->sfilename = filename;
 
-  if (!streq (cls->sfilename, filename))
+  if (!FILENAME_EQ (cls->sfilename, filename))
     m->def_filename = filename;
 
   m->def_regexp = regexp;
@@ -919,7 +925,7 @@
   if (!found)
     {
       if (!global_symbols->filename
-	  || !streq (global_symbols->filename, filename))
+	  || !FILENAME_EQ (global_symbols->filename, filename))
 	m->filename = filename;
 
       m->regexp = regexp;
@@ -3376,12 +3382,13 @@
   static char *buffer;
   static int buffer_size;
   struct search_path *path;
+  int flen = strlen (file) + 1;	/* +1 for the slash */
   
   filename = xstrdup (file);
 
   for (path = search_path; path && fp == NULL; path = path->next)
     {
-      int len = strlen (path->path);
+      int len = strlen (path->path) + flen;
 
       if (len + 1 >= buffer_size)
 	{
@@ -3485,10 +3492,12 @@
 	    }
 	  
 	  nbytes = fread (inbuffer + nread, 1, READ_CHUNK_SIZE, fp);
+	  if (nbytes <= 0)
+	    break;
 	  nread += nbytes;
-	  if (nbytes < READ_CHUNK_SIZE)
-	    break;
 	}
+      if (nread < 0)
+	nread = 0;
       inbuffer[nread] = '\0';
 
       /* Reinitialize scanner and parser for the new input file.  */