Annotation of /trunk/xorg-old/patches-6.9.0-r1/4152_all_4.3.0-allow-xdm-server-quotes.patch
Parent Directory | Revision Log
Revision 167 -
(hide annotations)
(download)
Tue May 8 20:58:51 2007 UTC (17 years, 4 months ago) by niro
File size: 1585 byte(s)
Tue May 8 20:58:51 2007 UTC (17 years, 4 months ago) by niro
File size: 1585 byte(s)
-import
1 | niro | 167 | --- xc/programs/xdm/file.c.old 2004-02-17 22:55:03.000000000 +1100 |
2 | +++ xc/programs/xdm/file.c 2004-03-02 23:23:42.243627680 +1100 | ||
3 | @@ -39,6 +39,7 @@ | ||
4 | # include "dm_error.h" | ||
5 | |||
6 | # include <ctype.h> | ||
7 | +# include <stdbool.h> | ||
8 | |||
9 | static int | ||
10 | DisplayTypeMatch (DisplayType d1, DisplayType d2) | ||
11 | @@ -62,11 +63,14 @@ | ||
12 | splitIntoWords (char *s) | ||
13 | { | ||
14 | char **args, **newargs; | ||
15 | - char *wordStart; | ||
16 | + char *wordStart, *thisToken; | ||
17 | int nargs; | ||
18 | - | ||
19 | + bool spaceBreakable, hadQuotes; | ||
20 | + static char DOUBLE_QUOTE=34, SINGLE_QUOTE=39; | ||
21 | + | ||
22 | args = 0; | ||
23 | nargs = 0; | ||
24 | + spaceBreakable = true; | ||
25 | while (*s) | ||
26 | { | ||
27 | while (*s && isspace (*s)) | ||
28 | @@ -74,8 +78,17 @@ | ||
29 | if (!*s || *s == '#') | ||
30 | break; | ||
31 | wordStart = s; | ||
32 | - while (*s && *s != '#' && !isspace (*s)) | ||
33 | + hadQuotes = false; | ||
34 | + while (*s && *s != '#') | ||
35 | + { | ||
36 | + if (spaceBreakable && isspace (*s)) | ||
37 | + break; | ||
38 | + if (*s == DOUBLE_QUOTE || *s == SINGLE_QUOTE){ | ||
39 | + spaceBreakable = !spaceBreakable; | ||
40 | + hadQuotes = true; | ||
41 | + } | ||
42 | ++s; | ||
43 | + } | ||
44 | if (!args) | ||
45 | { | ||
46 | args = (char **) malloc (2 * sizeof (char *)); | ||
47 | @@ -93,14 +106,25 @@ | ||
48 | } | ||
49 | args = newargs; | ||
50 | } | ||
51 | - args[nargs] = malloc (s - wordStart + 1); | ||
52 | + | ||
53 | + args[nargs] = malloc (s - wordStart); | ||
54 | + | ||
55 | if (!args[nargs]) | ||
56 | { | ||
57 | freeFileArgs (args); | ||
58 | return NULL; | ||
59 | } | ||
60 | + | ||
61 | strncpy (args[nargs], wordStart, s - wordStart); | ||
62 | + | ||
63 | args[nargs][s-wordStart] = '\0'; | ||
64 | + | ||
65 | + /* Tidy up problems with quotes in file */ | ||
66 | + if (hadQuotes){ | ||
67 | + args[nargs][0] = ' '; | ||
68 | + args[nargs][s-wordStart-1] = ' '; | ||
69 | + } | ||
70 | + | ||
71 | ++nargs; | ||
72 | args[nargs] = NULL; | ||
73 | } |