home *** CD-ROM | disk | FTP | other *** search
/ Programming Win32 Under the API / ProgrammingWin32UnderTheApiPatVillani.iso / patches / binutils-2_9_4.diff next >
Text File  |  2000-01-26  |  21KB  |  634 lines

  1. Index: binutils-2.9.4/bfd/ChangeLog
  2. ===================================================================
  3. RCS file: /homes/khan/src/CVSROOT/cygwin/bfd/ChangeLog,v
  4. retrieving revision 1.1.1.1
  5. retrieving revision 1.3
  6. diff -u -3 -p -r1.1.1.1 -r1.3
  7. --- binutils-2.9.4/bfd/ChangeLog    1999/02/19 05:36:00    1.1.1.1
  8. +++ binutils-2.9.4/bfd/ChangeLog    1999/11/07 10:29:06    1.3
  9. @@ -1,3 +1,23 @@
  10. +Sun Nov  7 04:27:07 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  11. +
  12. +    * libbfd.c (__mingw_fseek): New function to work around Win9x
  13. +    f/lseek bug.
  14. +    (__mingw_fwrite): Likewise.
  15. +    (__mingw_is_win9x): New helper function.
  16. +
  17. +Fri Aug  6 23:41:35 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  18. +
  19. +        * section.c (SEC_SHARED): Define.
  20. +        * bfd-in2.h: Rebuild.
  21. +        * coffcode.h (sec_to_styp_flags): Handle SEC_SHARED. 
  22. +        (styp_to_sec_flags): Likewise.
  23. +        * peicode.h (coff_swap_scnhdr_out): Likewise.
  24. +
  25. +Sat Jun 26 21:09:44 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  26. +
  27. +    * peicode.h (coff_swap_scnhdr_out): Mark user-defined writable 
  28. +    sections as writable.
  29. +
  30.  Wed Sep 16 10:34:13 1998  Nick Clifton  <nickc@cygnus.com>
  31.  
  32.      * elf32-v850.c (v850_elf_symbol_processing): Move symbols in
  33. Index: binutils-2.9.4/bfd/bfd-in2.h
  34. ===================================================================
  35. RCS file: /homes/khan/src/CVSROOT/cygwin/bfd/bfd-in2.h,v
  36. retrieving revision 1.1.1.1
  37. retrieving revision 1.2
  38. diff -u -3 -p -r1.1.1.1 -r1.2
  39. --- binutils-2.9.4/bfd/bfd-in2.h    1999/02/19 05:36:01    1.1.1.1
  40. +++ binutils-2.9.4/bfd/bfd-in2.h    1999/11/07 10:26:12    1.2
  41. @@ -978,6 +978,9 @@ typedef struct sec
  42.          /* This section should not be subject to garbage collection.  */
  43.  #define SEC_KEEP 0x1000000
  44.  
  45. +        /* This section contains "shared" data. Only used on PE-coff.  */
  46. +#define SEC_SHARED 0x4000000
  47. +
  48.          /*  End of section flags.  */
  49.  
  50.          /* Some internal packed boolean fields.  */
  51. Index: binutils-2.9.4/bfd/coffcode.h
  52. ===================================================================
  53. RCS file: /homes/khan/src/CVSROOT/cygwin/bfd/coffcode.h,v
  54. retrieving revision 1.1.1.1
  55. retrieving revision 1.2
  56. diff -u -3 -p -r1.1.1.1 -r1.2
  57. --- binutils-2.9.4/bfd/coffcode.h    1999/02/19 05:36:02    1.1.1.1
  58. +++ binutils-2.9.4/bfd/coffcode.h    1999/11/07 10:26:12    1.2
  59. @@ -443,6 +443,8 @@ sec_to_styp_flags (sec_name, sec_flags)
  60.  #ifdef COFF_WITH_PE
  61.    if (sec_flags & SEC_LINK_ONCE)
  62.      styp_flags |= IMAGE_SCN_LNK_COMDAT;
  63. +  if (sec_flags & SEC_SHARED)
  64. +    styp_flags |= IMAGE_SCN_MEM_SHARED;
  65.  #endif
  66.  
  67.    return (styp_flags);
  68. @@ -576,6 +578,9 @@ styp_to_sec_flags (abfd, hdr, name)
  69.  #ifdef COFF_WITH_PE
  70.    if (styp_flags & IMAGE_SCN_LNK_REMOVE)
  71.      sec_flags |= SEC_EXCLUDE;
  72. +
  73. +  if (styp_flags & IMAGE_SCN_MEM_SHARED)
  74. +    sec_flags |= SEC_SHARED;
  75.  
  76.    if (styp_flags & IMAGE_SCN_LNK_COMDAT)
  77.      {
  78. Index: binutils-2.9.4/bfd/libbfd.c
  79. ===================================================================
  80. RCS file: /homes/khan/src/CVSROOT/cygwin/bfd/libbfd.c,v
  81. retrieving revision 1.1.1.1
  82. retrieving revision 1.2
  83. diff -u -3 -p -r1.1.1.1 -r1.2
  84. --- binutils-2.9.4/bfd/libbfd.c    1999/02/19 05:36:04    1.1.1.1
  85. +++ binutils-2.9.4/bfd/libbfd.c    1999/11/07 10:29:06    1.2
  86. @@ -518,6 +518,124 @@ bfd_get_file_window (abfd, offset, size,
  87.  
  88.  #endif /* USE_MMAP */
  89.  
  90. +#ifdef __MINGW32__
  91. +
  92. +/* The following is a complete hack, and will be removed to the runtime
  93. +   in the future.  */
  94. +
  95. +/*
  96. + * Workaround for limitations on win9x where a file contents are
  97. + * not zero'd out if you seek past the end and then write.  */
  98. +
  99. +#include <windows.h>
  100. +
  101. +#ifdef __GNUC__
  102. +# define INLINE __inline__
  103. +#endif
  104. +
  105. +#define ZEROBLOCKSIZE 512
  106. +static int __mingw_fseek_called;
  107. +
  108. +static INLINE int
  109. +__mingw_is_win9x ()
  110. +{
  111. +  static DWORD os_platform_id = -1;
  112. +
  113. +  if (os_platform_id == -1)
  114. +    {
  115. +      OSVERSIONINFO os_version_info;
  116. +      memset (&os_version_info, 0, sizeof (OSVERSIONINFO));
  117. +      os_version_info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
  118. +      GetVersionEx (&os_version_info);
  119. +
  120. +      os_platform_id = os_version_info.dwPlatformId;
  121. +    }
  122. +  
  123. +  /* Don't even bother to check for Win32s. */
  124. +  return os_platform_id == VER_PLATFORM_WIN32_WINDOWS;
  125. +}
  126. +
  127. +/* The fseek in Win9x runtime does not zero out the file if seeking past
  128. +   the end; if you don't want random stuff from your disk included in your
  129. +   output DLL/executable, use this version instead. On WinNT/Win2k, it
  130. +   just calls runtime fseek().  
  131. +   
  132. +   CHECK/FIXME: Does this work for both text and binary modes?? */ 
  133. +
  134. +static int
  135. +INLINE
  136. +__mingw_fseek (FILE *fp, long offset, int whence)
  137. +{
  138. +#undef fseek
  139. +  __mingw_fseek_called = 1;
  140. +  return fseek (fp, offset, whence);
  141. +}
  142. +
  143. +static int
  144. +__mingw_fwrite (const void *buffer, size_t size, size_t count, FILE *fp)
  145. +{
  146. +#undef fwrite
  147. +
  148. +  if (__mingw_is_win9x () && __mingw_fseek_called)
  149. +    {
  150. +      DWORD actual_length, current_position;
  151. +      __mingw_fseek_called = 0;
  152. +
  153. +      fflush (fp);
  154. +      actual_length = GetFileSize ((HANDLE) _get_osfhandle (fileno (fp)), 
  155. +                                   NULL);
  156. +      current_position = SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)),
  157. +                                         0, 0, FILE_CURRENT);
  158. +#ifdef DEBUG
  159. +      printf ("__mingw_fseek: current %ld, actual %ld\n", 
  160. +          current_position, actual_length);
  161. +#endif /* DEBUG */
  162. +      if (current_position > actual_length)
  163. +    {
  164. +      static char __mingw_zeros[ZEROBLOCKSIZE];
  165. +      long numleft;
  166. +
  167. +      SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)), 
  168. +                      0, 0, FILE_END);
  169. +      numleft = current_position - actual_length;
  170. +
  171. +#ifdef DEBUG
  172. +      printf ("__mingw_fseek: Seeking %ld bytes past end\n", numleft);
  173. +#endif /* DEBUG */
  174. +      while (numleft > 0)
  175. +        {
  176. +          DWORD nzeros = (numleft > ZEROBLOCKSIZE)
  177. +                         ? ZEROBLOCKSIZE : numleft;
  178. +          DWORD written;
  179. +          if (! WriteFile ((HANDLE) _get_osfhandle (fileno (fp)),
  180. +                           __mingw_zeros, nzeros, &written, NULL))
  181. +            {
  182. +          /* Best we can hope for, or at least DJ says so. */
  183. +              SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)), 
  184. +                              0, 0, FILE_BEGIN);
  185. +          return -1;
  186. +        }
  187. +          if (written < nzeros)
  188. +            {
  189. +          /* Likewise. */
  190. +              SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)), 
  191. +                              0, 0, FILE_BEGIN);
  192. +          return -1;
  193. +        }
  194. +
  195. +          numleft -= written;
  196. +        }
  197. +        FlushFileBuffers ((HANDLE) _get_osfhandle (fileno (fp)));
  198. +    }
  199. +    }
  200. +  return fwrite (buffer, size, count, fp);
  201. +}
  202. +
  203. +#define fseek __mingw_fseek
  204. +#define fwrite __mingw_fwrite
  205. +
  206. +#endif /* __MINGW32__ */
  207. +
  208.  bfd_size_type
  209.  bfd_write (ptr, size, nitems, abfd)
  210.       CONST PTR ptr;
  211. Index: binutils-2.9.4/bfd/peicode.h
  212. ===================================================================
  213. RCS file: /homes/khan/src/CVSROOT/cygwin/bfd/peicode.h,v
  214. retrieving revision 1.1.1.1
  215. retrieving revision 1.2
  216. diff -u -3 -p -r1.1.1.1 -r1.2
  217. --- binutils-2.9.4/bfd/peicode.h    1999/02/19 05:36:04    1.1.1.1
  218. +++ binutils-2.9.4/bfd/peicode.h    1999/11/07 10:26:12    1.2
  219. @@ -1184,7 +1184,13 @@ coff_swap_scnhdr_out (abfd, in, out)
  220.      else if (strcmp (scnhdr_int->s_name, ".rsrc")  == 0)
  221.        flags |= IMAGE_SCN_MEM_READ | IMAGE_SCN_MEM_SHARED;
  222.      else
  223. -      flags |= IMAGE_SCN_MEM_READ;
  224. +      {
  225. +    flags |= IMAGE_SCN_MEM_READ;
  226. +    if (! (flags & SEC_READONLY))
  227. +      flags |= IMAGE_SCN_MEM_WRITE;
  228. +    if (flags & SEC_SHARED)
  229. +      flags |= IMAGE_SCN_MEM_SHARED;
  230. +      }
  231.  
  232.      bfd_h_put_32(abfd, flags, (bfd_byte *) scnhdr_ext->s_flags);
  233.    }
  234. Index: binutils-2.9.4/bfd/section.c
  235. ===================================================================
  236. RCS file: /homes/khan/src/CVSROOT/cygwin/bfd/section.c,v
  237. retrieving revision 1.1.1.1
  238. retrieving revision 1.2
  239. diff -u -3 -p -r1.1.1.1 -r1.2
  240. --- binutils-2.9.4/bfd/section.c    1999/02/19 05:36:04    1.1.1.1
  241. +++ binutils-2.9.4/bfd/section.c    1999/11/07 10:26:12    1.2
  242. @@ -307,6 +307,9 @@ CODE_FRAGMENT
  243.  .    {* This section should not be subject to garbage collection.  *}
  244.  .#define SEC_KEEP 0x1000000
  245.  .
  246. +.    {* This section contains "shared" data. Only used on PE-coff.  *}
  247. +.#define SEC_SHARED 0x4000000
  248. +.
  249.  .    {*  End of section flags.  *}
  250.  .
  251.  .    {* Some internal packed boolean fields.  *}
  252. Index: binutils-2.9.4/binutils/ChangeLog
  253. ===================================================================
  254. RCS file: /homes/khan/src/CVSROOT/cygwin/binutils/ChangeLog,v
  255. retrieving revision 1.1.1.1
  256. retrieving revision 1.4
  257. diff -u -3 -p -r1.1.1.1 -r1.4
  258. --- binutils-2.9.4/binutils/ChangeLog    1999/02/19 05:36:04    1.1.1.1
  259. +++ binutils-2.9.4/binutils/ChangeLog    1999/10/26 20:09:25    1.4
  260. @@ -1,3 +1,20 @@
  261. +Sat Aug 28 12:43:04 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  262. +
  263. +    * dlltool.c (scan_drectve_symbols): Handle type tags in exported
  264. +    symbols.
  265. +    (scan_filtered_symbols): Likewise.
  266. +
  267. +1999-02-17  DJ Delorie  <dj@cygnus.com>
  268. +
  269. +        * resbin.c (res_to_bin_versioninfo): Instead of entering a value
  270. +    length of zero in a version info string, enter the appropriate
  271. +    length.
  272. +
  273. +Sun Aug 29 16:51:36 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  274. +
  275. +    * dllwrap.c (long_options): Add -mno-cygwin flag.
  276. +    (main): Handle -mno-cygwin flag.
  277. +
  278.  Fri Oct 30 15:14:49 1998  Geoffrey Noer  <noer@cygnus.com>
  279.  
  280.      * dllwrap.c: change all references to cygwin32_ to cygwin_
  281. Index: binutils-2.9.4/binutils/dlltool.c
  282. ===================================================================
  283. RCS file: /homes/khan/src/CVSROOT/cygwin/binutils/dlltool.c,v
  284. retrieving revision 1.1.1.1
  285. retrieving revision 1.2
  286. diff -u -3 -p -r1.1.1.1 -r1.2
  287. --- binutils-2.9.4/binutils/dlltool.c    1999/02/19 05:36:05    1.1.1.1
  288. +++ binutils-2.9.4/binutils/dlltool.c    1999/10/26 20:09:25    1.2
  289. @@ -1083,7 +1083,9 @@ scan_drectve_symbols (abfd)
  290.    inform (_("Sucking in info from .drective section in %s\n"),
  291.        bfd_get_filename (abfd));
  292.  
  293. -  /* Search for -export: strings */
  294. +  /* Search for -export: strings. The exported symbols can optionally
  295. +     have type tags (eg., -export:foo,data), so handle those as well. 
  296. +     Currently only data tag is supported. */
  297.    p = buf;
  298.    e = buf + size;
  299.    while (p < e)
  300. @@ -1093,25 +1095,36 @@ scan_drectve_symbols (abfd)
  301.      {
  302.        char * name;
  303.        char * c;
  304. +      flagword flags = BSF_FUNCTION;
  305.        
  306.        p += 8;
  307.        name = p;
  308. -      while (p < e && *p != ' ' && *p != '-')
  309. +      while (p < e && *p != ',' && *p != ' ' && *p != '-')
  310.          p++;
  311.        c = xmalloc (p - name + 1);
  312.        memcpy (c, name, p - name);
  313.        c[p - name] = 0;
  314. +      if (p < e && *p == ',')    /* found type tag. */
  315. +        {
  316. +          char *tag_start = ++p;
  317. +          while (p < e && *p != ' ' && *p != '-')
  318. +        p++;
  319. +          if (strncmp (tag_start, "data", 4) == 0)
  320. +            flags &= ~BSF_FUNCTION;
  321. +        }
  322. +
  323.  
  324.        /* FIXME: The 5th arg is for the `constant' field.
  325.           What should it be?  Not that it matters since it's not
  326.           currently useful.  */
  327. -      def_exports (c, 0, -1, 0, 0, 0);
  328. +      def_exports (c, 0, -1, 0, 0, ! (flags & BSF_FUNCTION));
  329.  
  330.        if (add_stdcall_alias && strchr (c, '@'))
  331.          {
  332.            char *exported_name = xstrdup (c);
  333.            char *atsym = strchr (exported_name, '@');
  334.            *atsym = '\0';
  335. +          /* Note: stdcall alias symbols can never be data. */
  336.            def_exports (exported_name, xstrdup (c), -1, 0, 0, 0);
  337.          }
  338.      }
  339. @@ -1153,13 +1166,15 @@ scan_filtered_symbols (abfd, minisyms, s
  340.        if (bfd_get_symbol_leading_char (abfd) == symbol_name[0])
  341.      ++symbol_name;
  342.  
  343. -      def_exports (xstrdup (symbol_name) , 0, -1, 0, 0, 0);
  344. +      def_exports (xstrdup (symbol_name) , 0, -1, 0, 0,
  345. +                   ! (sym->flags & BSF_FUNCTION));
  346.  
  347.        if (add_stdcall_alias && strchr (symbol_name, '@'))
  348.          {
  349.        char *exported_name = xstrdup (symbol_name);
  350.        char *atsym = strchr (exported_name, '@');
  351.        *atsym = '\0';
  352. +      /* Note: stdcall alias symbols can never be data. */
  353.        def_exports (exported_name, xstrdup (symbol_name), -1, 0, 0, 0);
  354.      }
  355.      }
  356. Index: binutils-2.9.4/binutils/dllwrap.c
  357. ===================================================================
  358. RCS file: /homes/khan/src/CVSROOT/cygwin/binutils/dllwrap.c,v
  359. retrieving revision 1.1.1.1
  360. retrieving revision 1.2
  361. diff -u -3 -p -r1.1.1.1 -r1.2
  362. --- binutils-2.9.4/binutils/dllwrap.c    1999/02/19 05:36:05    1.1.1.1
  363. +++ binutils-2.9.4/binutils/dllwrap.c    1999/08/29 21:52:49    1.2
  364. @@ -379,9 +379,10 @@ usage (file, status)
  365.  #define OPTION_ENTRY        (OPTION_DLLTOOL_NAME + 1)
  366.  #define OPTION_IMAGE_BASE    (OPTION_ENTRY + 1)
  367.  #define OPTION_TARGET        (OPTION_IMAGE_BASE + 1)
  368. +#define OPTION_MNO_CYGWIN    (OPTION_TARGET + 1)
  369.  
  370.  /* DLLTOOL options. */
  371. -#define OPTION_NODELETE        (OPTION_TARGET + 1)
  372. +#define OPTION_NODELETE        (OPTION_MNO_CYGWIN + 1)
  373.  #define OPTION_DLLNAME        (OPTION_NODELETE + 1)
  374.  #define OPTION_NO_IDATA4     (OPTION_DLLNAME + 1)
  375.  #define OPTION_NO_IDATA5    (OPTION_NO_IDATA4 + 1)
  376. @@ -417,6 +418,7 @@ static const struct option long_options[
  377.    {"entry", required_argument, NULL, 'e'},
  378.    {"image-base", required_argument, NULL, OPTION_IMAGE_BASE},
  379.    {"target", required_argument, NULL, OPTION_TARGET},
  380. +  {"mno-cygwin", no_argument, NULL, OPTION_MNO_CYGWIN},
  381.  
  382.    /* dlltool options. */
  383.    {"no-delete", no_argument, NULL, 'n'},
  384. @@ -565,6 +567,10 @@ main (argc, argv)
  385.        break;
  386.      case OPTION_TARGET:
  387.        target = optarg;
  388. +      break;
  389. +    case OPTION_MNO_CYGWIN:
  390. +      target = "i386-mingw32";
  391. +      driver_arg = 1;
  392.        break;
  393.      case OPTION_BASE_FILE:
  394.        base_file_name = optarg;
  395. Index: binutils-2.9.4/binutils/resbin.c
  396. ===================================================================
  397. RCS file: /homes/khan/src/CVSROOT/cygwin/binutils/resbin.c,v
  398. retrieving revision 1.1.1.1
  399. retrieving revision 1.2
  400. diff -u -3 -p -r1.1.1.1 -r1.2
  401. --- binutils-2.9.4/binutils/resbin.c    1999/02/19 05:36:05    1.1.1.1
  402. +++ binutils-2.9.4/binutils/resbin.c    1999/08/29 21:53:40    1.2
  403. @@ -2257,7 +2257,6 @@ res_to_bin_versioninfo (versioninfo, big
  404.          vslen += 6;
  405.          vsslen = 6;
  406.  
  407. -        put_16 (big_endian, 0, vssd->data + 2);
  408.          put_16 (big_endian, 1, vssd->data + 4);
  409.  
  410.          *pp = vssd;
  411. @@ -2277,6 +2276,7 @@ res_to_bin_versioninfo (versioninfo, big
  412.          vsslen += length - hold;
  413.  
  414.          *pp = unicode_to_bin (vs->value, big_endian);
  415. +         put_16 (big_endian, (*pp)->length / 2, vssd->data + 2);
  416.          length += (*pp)->length;
  417.          vilen += (*pp)->length;
  418.          vslen += (*pp)->length;
  419. Index: binutils-2.9.4/gas/ChangeLog
  420. ===================================================================
  421. RCS file: /homes/khan/src/CVSROOT/cygwin/gas/ChangeLog,v
  422. retrieving revision 1.1.1.1
  423. retrieving revision 1.2
  424. diff -u -3 -p -r1.1.1.1 -r1.2
  425. --- binutils-2.9.4/gas/ChangeLog    1999/02/19 05:35:58    1.1.1.1
  426. +++ binutils-2.9.4/gas/ChangeLog    1999/11/07 10:24:58    1.2
  427. @@ -1,3 +1,13 @@
  428. +Fri Aug  6 23:44:22 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  429. +
  430. +        * config/obj-coff.c (obj_coff_section): Handle 's' (shared) section 
  431. +        flag.
  432. +
  433. +Sat Jun 26 21:09:44 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  434. +
  435. +        * config/obj-coff.c (obj_coff_section): Mark writable sections
  436. +        as data.
  437. +
  438.  Mon Aug 10 15:39:56 1998  Richard Henderson  <rth@cygnus.com>
  439.  
  440.      * config/tc-alpha.c (tc_gen_reloc): Bias WEAK symbols just as
  441. Index: binutils-2.9.4/gas/config/obj-coff.c
  442. ===================================================================
  443. RCS file: /homes/khan/src/CVSROOT/cygwin/gas/config/obj-coff.c,v
  444. retrieving revision 1.1.1.1
  445. retrieving revision 1.2
  446. diff -u -3 -p -r1.1.1.1 -r1.2
  447. --- binutils-2.9.4/gas/config/obj-coff.c    1999/02/19 05:35:58    1.1.1.1
  448. +++ binutils-2.9.4/gas/config/obj-coff.c    1999/11/07 10:24:59    1.2
  449. @@ -1133,6 +1133,7 @@ coff_frob_file_after_relocs ()
  450.   *                         'd' (apparently m88k for data)
  451.   *                                               'x' for text
  452.   *                         'r' for read-only data
  453. + *                         's' for shared data (pe-coff)
  454.   * But if the argument is not a quoted string, treat it as a
  455.   * subsegment number.
  456.   */
  457. @@ -1187,9 +1188,10 @@ obj_coff_section (ignore)
  458.          case 'b': flags |= SEC_ALLOC; flags &=~ SEC_LOAD; break;
  459.          case 'n': flags &=~ SEC_LOAD; break;
  460.          case 'd':
  461. -        case 'w': flags &=~ SEC_READONLY; break;
  462. +        case 'w': flags |= SEC_DATA; flags &=~ SEC_READONLY; break;
  463.          case 'x': flags |= SEC_CODE; break;
  464.          case 'r': flags |= SEC_READONLY; break;
  465. +        case 's': flags |= SEC_SHARED; break;
  466.  
  467.          case 'i': /* STYP_INFO */
  468.          case 'l': /* STYP_LIB */
  469. Index: binutils-2.9.4/libiberty/ChangeLog
  470. ===================================================================
  471. RCS file: /homes/khan/src/CVSROOT/cygwin/libiberty/ChangeLog,v
  472. retrieving revision 1.1.1.1
  473. retrieving revision 1.2
  474. diff -u -3 -p -r1.1.1.1 -r1.2
  475. --- binutils-2.9.4/libiberty/ChangeLog    1999/02/19 05:35:56    1.1.1.1
  476. +++ binutils-2.9.4/libiberty/ChangeLog    1999/11/07 10:24:38    1.2
  477. @@ -1,3 +1,15 @@
  478. +Fri Nov  5 03:55:13 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  479. +
  480. +    * pexecute.c (fix_argv): Handle embedded whitespace in args.
  481. +
  482. +Mon Aug 30 18:09:42 1999  Mumit Khan  <khan@xraylith.wisc.edu>
  483. +
  484. +    * basename.c (DIR_SEPARATOR): New macro.
  485. +    (DIR_SEPARATOR_2): Likewise.
  486. +    (HAVE_DOS_BASED_FILESYSTEM): Likewise.
  487. +    (IS_DIR_SEPARATOR): Likewise.
  488. +    (main): Handle MSDOS style pathname.
  489. +
  490.  Wed Nov 18 08:52:26 1998  Christopher Faylor <cgf@cygnus.com>
  491.  
  492.          * pexecute.c: Reorganize WIN32 case to accomodate Cygwin
  493. Index: binutils-2.9.4/libiberty/basename.c
  494. ===================================================================
  495. RCS file: /homes/khan/src/CVSROOT/cygwin/libiberty/basename.c,v
  496. retrieving revision 1.1.1.1
  497. retrieving revision 1.2
  498. diff -u -3 -p -r1.1.1.1 -r1.2
  499. --- binutils-2.9.4/libiberty/basename.c    1999/02/19 05:35:56    1.1.1.1
  500. +++ binutils-2.9.4/libiberty/basename.c    1999/11/07 10:24:38    1.2
  501. @@ -14,24 +14,53 @@ DESCRIPTION
  502.      last component of the pathname ("ls.c" in this case).
  503.  
  504.  BUGS
  505. -    Presumes a UNIX style path with UNIX style separators.
  506. +    Presumes a UNIX or DOS/Windows style path with UNIX or DOS/Windows 
  507. +    style separators.
  508.  */
  509.  
  510.  #include "ansidecl.h"
  511.  #include "libiberty.h"
  512. +#include <ctype.h>
  513.  
  514. +#ifndef DIR_SEPARATOR
  515. +#define DIR_SEPARATOR '/'
  516. +#endif
  517. +
  518. +#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
  519. +  defined (__OS2__)
  520. +#define HAVE_DOS_BASED_FILE_SYSTEM
  521. +#ifndef DIR_SEPARATOR_2 
  522. +#define DIR_SEPARATOR_2 '\\'
  523. +#endif
  524. +#endif
  525. +
  526. +/* Define IS_DIR_SEPARATOR.  */
  527. +#ifndef DIR_SEPARATOR_2
  528. +# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
  529. +#else /* DIR_SEPARATOR_2 */
  530. +# define IS_DIR_SEPARATOR(ch) \
  531. +    (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
  532. +#endif /* DIR_SEPARATOR_2 */
  533. +
  534.  char *
  535.  basename (name)
  536.       const char *name;
  537.  {
  538. -  const char *base = name;
  539. +  const char *base;
  540.  
  541. -  while (*name)
  542. +#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
  543. +  /* Skip over the disk name in MSDOS pathnames. */
  544. +  if (isalpha (name[0]) && name[1] == ':') 
  545. +    name += 2;
  546. +#endif
  547. +
  548. +  for (base = name; *name; name++)
  549.      {
  550. -      if (*name++ == '/')
  551. +      if (IS_DIR_SEPARATOR (*name))
  552.      {
  553. -      base = name;
  554. +      base = name + 1;
  555.      }
  556.      }
  557.    return (char *) base;
  558.  }
  559. +
  560. Index: binutils-2.9.4/libiberty/pexecute.c
  561. ===================================================================
  562. RCS file: /homes/khan/src/CVSROOT/cygwin/libiberty/pexecute.c,v
  563. retrieving revision 1.1.1.1
  564. retrieving revision 1.2
  565. diff -u -3 -p -r1.1.1.1 -r1.2
  566. --- binutils-2.9.4/libiberty/pexecute.c    1999/02/19 05:35:56    1.1.1.1
  567. +++ binutils-2.9.4/libiberty/pexecute.c    1999/11/07 10:24:38    1.2
  568. @@ -242,30 +242,44 @@ fix_argv (argvec)
  569.  {
  570.    int i;
  571.  
  572. -  for (i = 1; argvec[i] != 0; i++)
  573. +  for (i = 0; argvec[i] != 0; i++)
  574.      {
  575. -      int len, j;
  576. -      char *temp, *newtemp;
  577. -
  578. -      temp = argvec[i];
  579. -      len = strlen (temp);
  580. -      for (j = 0; j < len; j++)
  581. +      if (strpbrk (argvec[i], " \t"))
  582.          {
  583. -          if (temp[j] == '"')
  584. -            {
  585. -              newtemp = xmalloc (len + 2);
  586. -              strncpy (newtemp, temp, j);
  587. -              newtemp [j] = '\\';
  588. -              strncpy (&newtemp [j+1], &temp [j], len-j);
  589. -              newtemp [len+1] = 0;
  590. -              temp = newtemp;
  591. -              len++;
  592. -              j++;
  593. -            }
  594. -        }
  595. +      int len, trailing_backslash;
  596. +      char *temp, *newtemp;
  597. +
  598. +      len = strlen (argvec[i]);
  599. +      trailing_backslash = 0;
  600. +
  601. +      /* There is an added complication when an arg with embedded white
  602. +         space ends in a backslash (such as in the case of -iprefix arg
  603. +         passed to cpp). The resulting quoted strings gets misinterpreted
  604. +         by the command interpreter -- it thinks that the ending quote
  605. +         is escaped by the trailing backslash and things get confused. 
  606. +         We handle this case by escaping the trailing backslash, provided
  607. +         it was not escaped in the first place.  */
  608. +      if (len > 1 
  609. +          && argvec[i][len-1] == '\\' 
  610. +          && argvec[i][len-2] != '\\')
  611. +        {
  612. +          trailing_backslash = 1;
  613. +          ++len;            /* to escape the final backslash. */
  614. +        }
  615. +
  616. +      len += 2;            /* and for the enclosing quotes. */
  617. +
  618. +      temp = xmalloc (len + 1);
  619. +      temp[0] = '"';
  620. +      strcpy (temp + 1, argvec[i]);
  621. +      if (trailing_backslash)
  622. +        temp[len-2] = '\\';
  623. +      temp[len-1] = '"';
  624. +      temp[len] = '\0';
  625.  
  626. -        argvec[i] = temp;
  627. -      }
  628. +      argvec[i] = temp;
  629. +    }
  630. +    }
  631.  
  632.    return (const char * const *) argvec;
  633.  }
  634.