Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
22e50c5b
Commit
22e50c5b
authored
May 30, 2000
by
Bruce Korb
Committed by
Bruce Korb
May 30, 2000
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
restore old algorighm for char_macro_*_fix routines
From-SVN: r34271
parent
26e903ee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
148 additions
and
175 deletions
+148
-175
gcc/ChangeLog
+1
-0
gcc/fixinc/fixfixes.c
+138
-153
gcc/fixinc/inclhack.def
+9
-22
No files found.
gcc/ChangeLog
View file @
22e50c5b
2000
-
05
-
30
Bruce
Korb
<
bkorb
@gnu
.
org
>
2000
-
05
-
30
Bruce
Korb
<
bkorb
@gnu
.
org
>
*
fixinc
/
tests
/*: Added expected result files for fixinc's make check
*
fixinc
/
tests
/*: Added expected result files for fixinc's make check
* fixinc/fixfixes(char_macro_*_fix): Restore original algorithm
2000-05-30 Richard Henderson <rth@cygnus.com>
2000-05-30 Richard Henderson <rth@cygnus.com>
gcc/fixinc/fixfixes.c
View file @
22e50c5b
...
@@ -24,7 +24,7 @@ Here are the rules:
...
@@ -24,7 +24,7 @@ Here are the rules:
4. Do not read anything from stdin. It is closed.
4. Do not read anything from stdin. It is closed.
5. Write to stderr only in the event of a reportable error
5. Write to stderr only in the event of a reportable error
In such an event, call "exit
(1
)".
In such an event, call "exit
(EXIT_FAILURE
)".
6. You have access to the fixDescList entry for the fix in question.
6. You have access to the fixDescList entry for the fix in question.
This may be useful, for example, if there are interesting strings
This may be useful, for example, if there are interesting strings
...
@@ -59,6 +59,10 @@ Boston, MA 02111-1307, USA. */
...
@@ -59,6 +59,10 @@ Boston, MA 02111-1307, USA. */
#include "fixlib.h"
#include "fixlib.h"
tSCC
zNeedsArg
[]
=
"fixincl error: `%s' needs %s argument (c_fix_arg[%d])
\n
"
;
#define EXIT_BROKEN 3
typedef
struct
{
typedef
struct
{
const
char
*
fix_name
;
const
char
*
fix_name
;
void
(
*
fix_proc
)();
void
(
*
fix_proc
)();
...
@@ -192,7 +196,6 @@ format_write (format, text, av)
...
@@ -192,7 +196,6 @@ format_write (format, text, av)
*/
*/
FIX_PROC_HEAD
(
format_fix
)
FIX_PROC_HEAD
(
format_fix
)
{
{
tSCC
zBad
[]
=
"fixincl error: `%s' needs %s c_fix_arg
\n
"
;
tCC
*
pz_pat
=
p_fixd
->
patch_args
[
2
];
tCC
*
pz_pat
=
p_fixd
->
patch_args
[
2
];
tCC
*
pz_fmt
=
p_fixd
->
patch_args
[
1
];
tCC
*
pz_fmt
=
p_fixd
->
patch_args
[
1
];
const
char
*
p
;
const
char
*
p
;
...
@@ -204,8 +207,8 @@ FIX_PROC_HEAD( format_fix )
...
@@ -204,8 +207,8 @@ FIX_PROC_HEAD( format_fix )
*/
*/
if
(
pz_fmt
==
(
tCC
*
)
NULL
)
if
(
pz_fmt
==
(
tCC
*
)
NULL
)
{
{
fprintf
(
stderr
,
z
Bad
,
p_fixd
->
fix_name
,
"replacement-format"
);
fprintf
(
stderr
,
z
NeedsArg
,
p_fixd
->
fix_name
,
"replacement format"
,
0
);
exit
(
3
);
exit
(
EXIT_BROKEN
);
}
}
/*
/*
...
@@ -220,8 +223,8 @@ FIX_PROC_HEAD( format_fix )
...
@@ -220,8 +223,8 @@ FIX_PROC_HEAD( format_fix )
{
{
if
(
ct
--
<=
0
)
if
(
ct
--
<=
0
)
{
{
fprintf
(
stderr
,
z
Bad
,
p_fixd
->
fix_name
,
"search-text"
);
fprintf
(
stderr
,
z
NeedsArg
,
p_fixd
->
fix_name
,
"search text"
,
1
);
exit
(
3
);
exit
(
EXIT_BROKEN
);
}
}
if
(
pTD
->
type
==
TT_EGREP
)
if
(
pTD
->
type
==
TT_EGREP
)
...
@@ -271,71 +274,72 @@ FIX_PROC_HEAD( char_macro_use_fix )
...
@@ -271,71 +274,72 @@ FIX_PROC_HEAD( char_macro_use_fix )
{
{
/* This regexp looks for a traditional-syntax #define (# in column 1)
/* This regexp looks for a traditional-syntax #define (# in column 1)
of an object-like macro. */
of an object-like macro. */
static
const
char
zPatFmt
[]
=
static
const
char
pat
[]
=
#ifdef __STDC__
"^#[
\t
]*define[
\t
]+[_A-Za-z][_A-Za-z0-9]*[
\t
]+"
;
/*
* Match up to the replacement text
*/
"^#[
\t
]*define[
\t
]+[_A-Za-z][_A-Za-z0-9]*[
\t
]+"
/*
* Match the replacement macro name and openening parenthesis
*/
"[_A-Z][_A-Z0-9]*%s[A-Z]*
\\
("
/*
* Match the single character that must be single-quoted,
* plus some other non-name type character
*/
"([A-Za-z])[^a-zA-Z0-9_]"
#else
/*
* Indecipherable gobbeldygook:
*/
"^#[
\t
]*define[
\t
]+[_A-Za-z][_A-Za-z0-9]*[
\t
]+[_A-Z][_A-Z0-9]*\
%s[A-Z]*
\\
(([A-Za-z])[^a-zA-Z0-9_]"
#endif
;
# define SUB_PAT_CT 1
char
*
pz_pat
;
static
regex_t
re
;
static
regex_t
re
;
regmatch_t
rm
[
SUB_PAT_CT
+
1
];
const
char
*
str
=
p_fixd
->
patch_args
[
1
];
regmatch_t
rm
[
1
];
if
(
p_fixd
->
patch_args
[
1
]
==
NULL
)
const
char
*
p
,
*
limit
;
{
size_t
len
;
fprintf
(
stderr
,
"%s needs macro-name-string argument"
,
p_fixd
->
fix_name
);
exit
(
3
);
}
asprintf
(
&
pz_pat
,
zPatFmt
,
p_fixd
->
patch_args
[
1
]);
if
(
str
==
NULL
)
if
(
!
pz_pat
)
{
{
fprintf
(
stderr
,
"Virtual memory exhausted
\n
"
);
fprintf
(
stderr
,
zNeedsArg
,
p_fixd
->
fix_name
,
"ioctl type"
,
0
);
exit
(
3
);
exit
(
EXIT_BROKEN
);
}
}
compile_re
(
pz_pat
,
&
re
,
1
,
"macro pattern"
,
"char_macro_use_fix"
);
len
=
strlen
(
str
);
free
(
pz_pat
);
compile_re
(
pat
,
&
re
,
1
,
"macro pattern"
,
"char_macro_use_fix"
);
while
(
regexec
(
&
re
,
text
,
SUB_PAT_CT
+
1
,
rm
,
0
)
==
0
)
for
(
p
=
text
;
regexec
(
&
re
,
p
,
1
,
rm
,
0
)
==
0
;
p
=
limit
+
1
)
{
{
const
char
*
pz
=
text
+
rm
[
1
].
rm_so
;
/* p + rm[0].rm_eo is the first character of the macro replacement.
Find the end of the macro replacement, and the STR we were
/*
sent to look for within the replacement. */
* Write up to, but not including, the character we must quote
p
+=
rm
[
0
].
rm_eo
;
*/
limit
=
p
-
1
;
fwrite
(
text
,
1
,
rm
[
1
].
rm_so
,
stdout
);
do
fputc
(
'\''
,
stdout
);
{
fputc
(
*
(
pz
++
),
stdout
);
limit
=
strchr
(
limit
+
1
,
'\n'
);
fputc
(
'\''
,
stdout
);
if
(
!
limit
)
text
=
pz
;
goto
done
;
}
}
while
(
limit
[
-
1
]
==
'\\'
);
do
{
if
(
*
p
==
str
[
0
]
&&
!
strncmp
(
p
+
1
,
str
+
1
,
len
-
1
))
goto
found
;
}
while
(
++
p
<
limit
-
len
);
/* Hit end of line. */
continue
;
found
:
/* Found STR on this line. If the macro needs fixing,
the next few chars will be whitespace or uppercase,
then an open paren, then a single letter. */
while
((
isspace
(
*
p
)
||
isupper
(
*
p
))
&&
p
<
limit
)
p
++
;
if
(
*
p
++
!=
'('
)
continue
;
if
(
!
isalpha
(
*
p
))
continue
;
if
(
isalnum
(
p
[
1
])
||
p
[
1
]
==
'_'
)
continue
;
/* Splat all preceding text into the output buffer,
quote the character at p, then proceed. */
fwrite
(
text
,
1
,
p
-
text
,
stdout
);
putchar
(
'\''
);
putchar
(
*
p
);
putchar
(
'\''
);
text
=
p
+
1
;
}
done
:
fputs
(
text
,
stdout
);
fputs
(
text
,
stdout
);
# undef SUB_PAT_CT
}
}
...
@@ -352,107 +356,88 @@ FIX_PROC_HEAD( char_macro_use_fix )
...
@@ -352,107 +356,88 @@ FIX_PROC_HEAD( char_macro_use_fix )
you provide as the `c_fix_arg' argument. */
you provide as the `c_fix_arg' argument. */
FIX_PROC_HEAD
(
char_macro_def_fix
)
FIX_PROC_HEAD
(
char_macro_def_fix
)
{
{
static
const
char
zPatFmt
[]
=
/* This regexp looks for any traditional-syntax #define (# in column 1). */
#ifdef __STDC__
static
const
char
pat
[]
=
/*
"^#[
\t
]*define[
\t
]+"
;
* Find a #define name and opening parenthesis
*/
"^#[
\t
]*define[
\t
]+[_A-Z][A-Z0-9_]*%s[A-Z]*
\\
("
/*
* The next character must match a later one
*/
"([a-zA-Z])"
/* rm[1] */
/*
* now match over a comma, the argument list, intervening white space
* an opening parenthesis, and on through a single quote character
*/
"[
\t
]*,[^)]*
\\
)[
\t
]+
\\
([^']*'"
/*
* Match the character that must match the remembered char above
*/
"([a-zA-Z])'"
/* rm[2] */
#else
/*
* Indecipherable gobbeldygook:
*/
"^#[
\t
]*define[
\t
]+[_A-Z][A-Z0-9_]*%s[A-Z]*
\\
(\
([a-zA-Z])[
\t
]*,[^)]*
\\
)[
\t
]+
\\
([^']*'([a-zA-Z])'"
#endif
;
char
*
pz_pat
;
static
regex_t
re
;
static
regex_t
re
;
# define SUB_PAT_CT 2
regmatch_t
rm
[
SUB_PAT_CT
+
1
];
const
char
*
p
;
int
rerr
;
if
(
p_fixd
->
patch_args
[
1
]
==
NULL
)
const
char
*
str
=
p_fixd
->
patch_args
[
1
];
{
regmatch_t
rm
[
1
];
fprintf
(
stderr
,
"%s needs macro-name-string argument"
,
const
char
*
p
,
*
limit
;
p_fixd
->
fix_name
);
char
arg
;
exit
(
3
);
size_t
len
;
}
asprintf
(
&
pz_pat
,
zPatFmt
,
p_fixd
->
patch_args
[
1
]);
if
(
str
==
NULL
)
if
(
!
pz_pat
)
{
{
fprintf
(
stderr
,
"Virtual memory exhausted
\n
"
);
fprintf
(
stderr
,
zNeedsArg
,
p_fixd
->
fix_name
,
"ioctl type"
,
0
);
exit
(
3
);
exit
(
EXIT_BROKEN
);
}
}
compile_re
(
pz_pat
,
&
re
,
1
,
"macro pattern"
,
"char_macro_def_fix"
);
len
=
strlen
(
str
);
compile_re
(
pat
,
&
re
,
1
,
"macro pattern"
,
"fix_char_macro_defines"
);
#ifdef DEBUG
for
(
p
=
text
;
if
((
rerr
=
regexec
(
&
re
,
text
,
SUB_PAT_CT
+
1
,
rm
,
0
))
!=
0
)
regexec
(
&
re
,
p
,
1
,
rm
,
0
)
==
0
;
p
=
limit
+
1
)
{
{
fprintf
(
stderr
,
"Match error %d:
\n
%s
\n
"
,
rerr
,
pz_pat
);
/* p + rm[0].rm_eo is the first character of the macro name.
exit
(
3
);
Find the end of the macro replacement, and the STR we were
}
sent to look for within the name. */
#endif
p
+=
rm
[
0
].
rm_eo
;
limit
=
p
-
1
;
free
(
pz_pat
);
do
{
while
((
rerr
=
regexec
(
&
re
,
text
,
SUB_PAT_CT
+
1
,
rm
,
0
))
==
0
)
limit
=
strchr
(
limit
+
1
,
'\n'
);
{
if
(
!
limit
)
const
char
*
pz
=
text
+
rm
[
2
].
rm_so
;
goto
done
;
}
/*
while
(
limit
[
-
1
]
==
'\\'
);
* Write up to, but not including, the opening single quote.
*/
fwrite
(
text
,
1
,
rm
[
2
].
rm_so
-
1
,
stdout
);
/*
* The character inside the single quotes must match the
* first single-character macro argument
*/
if
(
text
[
rm
[
1
].
rm_so
]
!=
*
pz
)
{
/*
* Advance text past what we have written out and continue
*/
text
=
pz
-
1
;
continue
;
}
/*
* emit the now unquoted character
*/
putchar
(
*
pz
);
/*
do
* Point text to the character after the closing single quote
{
*/
if
(
*
p
==
str
[
0
]
&&
!
strncmp
(
p
+
1
,
str
+
1
,
len
-
1
))
text
=
pz
+
2
;
goto
found
;
p
++
;
}
while
(
isalpha
(
*
p
)
||
isalnum
(
*
p
)
||
*
p
==
'_'
);
/* Hit end of macro name without finding the string. */
continue
;
found
:
/* Found STR in this macro name. If the macro needs fixing,
there may be a few uppercase letters, then there will be an
open paren with _no_ intervening whitespace, and then a
single letter. */
while
(
isupper
(
*
p
)
&&
p
<
limit
)
p
++
;
if
(
*
p
++
!=
'('
)
continue
;
if
(
!
isalpha
(
*
p
))
continue
;
if
(
isalnum
(
p
[
1
])
||
p
[
1
]
==
'_'
)
continue
;
/* The character at P is the one to look for in the following
text. */
arg
=
*
p
;
p
+=
2
;
while
(
p
<
limit
)
{
if
(
p
[
-
1
]
==
'\''
&&
p
[
0
]
==
arg
&&
p
[
1
]
==
'\''
)
{
/* Remove the quotes from this use of ARG. */
p
--
;
fwrite
(
text
,
1
,
p
-
text
,
stdout
);
putchar
(
arg
);
p
+=
3
;
text
=
p
;
}
else
p
++
;
}
}
}
done
:
/*
* Emit the rest of the text
*/
fputs
(
text
,
stdout
);
fputs
(
text
,
stdout
);
# undef SUB_PAT_CT
}
}
/* Fix for machine name #ifdefs that are not in the namespace reserved
/* Fix for machine name #ifdefs that are not in the namespace reserved
...
@@ -636,9 +621,9 @@ apply_fix( p_fixd, filname )
...
@@ -636,9 +621,9 @@ apply_fix( p_fixd, filname )
break
;
break
;
if
(
--
ct
<=
0
)
if
(
--
ct
<=
0
)
{
{
fprintf
(
stderr
,
"fixincl
udes
error: the `%s' fix is unknown
\n
"
,
fprintf
(
stderr
,
"fixincl error: the `%s' fix is unknown
\n
"
,
fixname
);
fixname
);
exit
(
3
);
exit
(
EXIT_BROKEN
);
}
}
pfe
++
;
pfe
++
;
}
}
...
...
gcc/fixinc/inclhack.def
View file @
22e50c5b
...
@@ -832,7 +832,8 @@ fix = {
...
@@ -832,7 +832,8 @@ fix = {
select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z],";
select = "define[ \t]+[A-Z0-9_]+CTRL\\([a-zA-Z],";
c_fix = char_macro_def;
c_fix = char_macro_def;
c_fix_arg = "CTRL";
c_fix_arg = "CTRL";
test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)";
test_text = "#define BSD43_CTRL(n, x) (('n'<<8)+x)\n"
"#define _CTRL(c) ('c'&037)";
};
};
fix = {
fix = {
...
@@ -840,7 +841,7 @@ fix = {
...
@@ -840,7 +841,7 @@ fix = {
select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
select = "define[ \t]+[A-Z0-9_]+[ \t]+[A-Z0-9_]+CTRL[ \t]*\\( *[^,']";
c_fix = char_macro_use;
c_fix = char_macro_use;
c_fix_arg = "CTRL";
c_fix_arg = "CTRL";
test_text = "#define T
IOC
FOO BSD43_CTRL(T, 1)";
test_text = "#define T
CTRL
FOO BSD43_CTRL(T, 1)";
};
};
...
@@ -1097,7 +1098,9 @@ fix = {
...
@@ -1097,7 +1098,9 @@ fix = {
"\\( *[^,']";
"\\( *[^,']";
c_fix = char_macro_use;
c_fix = char_macro_use;
c_fix_arg = "IO";
c_fix_arg = "IO";
test_text = "#define TIOCFOO BSD43__IOWR(T, 1)";
test_text = "#define TIOCFOO BSD43__IOWR(T, 1)\n"
"#define TIOCFOO \\\\\n"
"BSD43__IOWR(T, 1) /* Some are multi-line */";
};
};
...
@@ -1797,22 +1800,6 @@ fix = {
...
@@ -1797,22 +1800,6 @@ fix = {
/*
/*
* Sony NEWSOS 5.0 does not support the complete ANSI C standard.
*/
#ifdef SONY
fix = {
hackname = sony_stdio;
files = stdio.h;
test = " -x /bin/sony";
test = " ! -z \"`if /bin/sony ; then echo true ; fi`\"";
sed = "s/__filbuf/_filbuf/g\n"
"s/__flsbuf/_flsbuf/g\n"
"s/__iob/_iob/g";
};
#endif
/*
* Incorrect #include in Sony News-OS 3.2.
* Incorrect #include in Sony News-OS 3.2.
*/
*/
fix = {
fix = {
...
@@ -2719,9 +2706,9 @@ fix = {
...
@@ -2719,9 +2706,9 @@ fix = {
select = "in_port_t";
select = "in_port_t";
#ifndef SVR5
#ifndef SVR5
mach = "*-*-sysv4*";
mach = "*-*-sysv4*";
mach = "i
[34567]
86-*-sysv5*";
mach = "i
?
86-*-sysv5*";
mach = "i
[34567]
86-*-udk*";
mach = "i
?
86-*-udk*";
mach = "i
[34567]
86-*-solaris2.[0-4]";
mach = "i
?
86-*-solaris2.[0-4]";
mach = "powerpcle-*-solaris2.[0-4]";
mach = "powerpcle-*-solaris2.[0-4]";
mach = "sparc-*-solaris2.[0-4]";
mach = "sparc-*-solaris2.[0-4]";
#endif /* SVR5 */
#endif /* SVR5 */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment