texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/makeinfo files.c,1.9,1.10 makeinfo.c,1.34,1.35


From: dirt
Subject: texinfo/makeinfo files.c,1.9,1.10 makeinfo.c,1.34,1.35
Date: Sat, 31 Jan 2004 13:50:10 +0100

Update of /cvsroot/texinfo/texinfo/makeinfo
In directory sheep:/tmp/cvs-serv23581/makeinfo

Modified Files:
        files.c makeinfo.c 
Log Message:
2004-01-31  Alper Ersoy  <address@hidden>

        * makeinfo/files.c (prepend_to_include_path, append_to_include_path)
        (pop_path_from_include_path): new functions to manipulate
        include_files_path.

        * makeinfo/makeinfo.c (convert_from_file): prepend the loaded file's
        path to include_files_path in order to make relative include files to
        be found, then remove afterwards.
        (main): make use of new functions for -I and -P options. 



Index: files.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/files.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** files.c     29 Jan 2004 01:20:51 -0000      1.9
--- files.c     31 Jan 2004 12:50:07 -0000      1.10
***************
*** 132,135 ****
--- 132,186 ----
    return NULL;
  }
+ 
+ /* Prepend and append new paths to include_files_path.  */
+ void
+ prepend_to_include_path (path)
+      char *path;
+ {
+   if (!include_files_path)
+     {
+       include_files_path = xstrdup (path);
+       include_files_path = xrealloc (include_files_path,
+           strlen (include_files_path) + 3); /* 3 for ":.\0" */
+       strcat (strcat (include_files_path, PATH_SEP), ".");
+     }
+   else
+     {
+       char *tmp = xstrdup (include_files_path);
+       include_files_path = xrealloc (include_files_path,
+           strlen (include_files_path) + strlen (path) + 2); /* 2 for ":\0" */
+       strcpy (include_files_path, path);
+       strcat (include_files_path, PATH_SEP);
+       strcat (include_files_path, tmp);
+       free (tmp);
+     }
+ }
+ 
+ void
+ append_to_include_path (path)
+      char *path;
+ {
+   if (!include_files_path)
+     include_files_path = xstrdup (".");
+ 
+   include_files_path = (char *) xrealloc (include_files_path,
+         2 + strlen (include_files_path) + strlen (path));
+   strcat (include_files_path, PATH_SEP);
+   strcat (include_files_path, path);
+ }
+ 
+ /* Remove the first path from the include_files_path.  */
+ void
+ pop_path_from_include_path ()
+ {
+   int i;
+ 
+   if (include_files_path)
+     for (i = 0; i < strlen (include_files_path)
+         && include_files_path[i] != ':'; i++);
+ 
+   /* Advance include_files_path to the next char from ':'  */
+   include_files_path += i+1;
+ }
  
  /* Find and load the file named FILENAME.  Return a pointer to

Index: makeinfo.c
===================================================================
RCS file: /cvsroot/texinfo/texinfo/makeinfo/makeinfo.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** makeinfo.c  29 Jan 2004 01:20:51 -0000      1.34
--- makeinfo.c  31 Jan 2004 12:50:07 -0000      1.35
***************
*** 682,693 ****
          case 'I':
            /* Append user-specified dir to include file path. */
!           if (!include_files_path)
!             include_files_path = xstrdup (".");
! 
!           include_files_path = (char *)
!             xrealloc (include_files_path,
!                       2 + strlen (include_files_path) + strlen (optarg));
!           strcat (include_files_path, PATH_SEP);
!           strcat (include_files_path, optarg);
            break;
  
--- 682,686 ----
          case 'I':
            /* Append user-specified dir to include file path. */
!           append_to_include_path (optarg);
            break;
  
***************
*** 709,729 ****
          case 'P':
            /* Prepend user-specified include dir to include path. */
!           if (!include_files_path)
!             {
!               include_files_path = xstrdup (optarg);
!               include_files_path = xrealloc (include_files_path,
!                            strlen (include_files_path) + 3); /* 3 for ":.\0" 
*/
!               strcat (strcat (include_files_path, PATH_SEP), ".");
!             }
!           else
!             {
!               char *tmp = xstrdup (include_files_path);
!               include_files_path = xrealloc (include_files_path,
!           strlen (include_files_path) + strlen (optarg) + 2); /* 2 for ":\0" 
*/
!               strcpy (include_files_path, optarg);
!               strcat (include_files_path, ":");
!               strcat (include_files_path, tmp);
!               free (tmp);
!             }
            break;
  
--- 702,706 ----
          case 'P':
            /* Prepend user-specified include dir to include path. */
!           prepend_to_include_path (optarg);
            break;
  
***************
*** 1382,1385 ****
--- 1359,1365 ----
    char *filename = xmalloc (strlen (name) + 50);
  
+   /* Prepend file directory to the search path, so relative links work.  */
+   prepend_to_include_path (pathname_part (name));
+ 
    initialize_conversion ();
  
***************
*** 1413,1416 ****
--- 1393,1400 ----
  
    convert_from_loaded_file (name);
+ 
+   /* Pop the prepended path, so multiple filenames in the
+      command line do not screw each others include paths.  */
+   pop_path_from_include_path ();
  }
  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]