This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Factorization of some code.
- To: egcs-patches at cygnus dot com
- Subject: Factorization of some code.
- From: Theodore Papadopoulo <Theodore dot Papadopoulo at sophia dot inria dot fr>
- Date: Thu, 14 Jan 1999 00:27:46 +0100
This trivial patch just factorizes the code needed to decode options
with a trailing integer parameter (currently -ftemplate-depth-<n>
and -fmangling-version-<n>). The factorized code is in a new function
named read_integral_parameter. The code for decoding -Oxxx can also
benefit from this function with little work (This is a little less
trivial. I will do the work if this patch gets accepted and if no-one
finds objections to do so.).
Note: This was included in a previous patch I posted (see the
Re: g++ memory bug. thread).
I guess, I should have split it from the begining...
Index: ChangeLog
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/ChangeLog,v
retrieving revision 1.2762
diff -c -3 -p -r1.2762 ChangeLog
*** ChangeLog 1999/01/13 14:32:34 1.2762
--- ChangeLog 1999/01/13 23:13:31
***************
*** 1,3 ****
--- 1,9 ----
+ Fri Jan 8 17:45:23 1999 Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr>
+
+ * topvel.h: Declare new function read_integral_parameter for
+ reading flags finishing with an integral constant.
+ * toplevl.c: Define it here.
+
Wed Jan 13 16:16:44 1999 Catherine Moore <clm@cygnus.com>
* config/arm.c (output_func_epilogue): Check TARGET_ABORT_NORETURN
Index: toplev.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.c,v
retrieving revision 1.143
diff -c -3 -p -r1.143 toplev.c
*** toplev.c 1999/01/08 00:54:46 1.143
--- toplev.c 1999/01/13 22:57:13
*************** FILE *asm_out_file;
*** 1221,1226 ****
--- 1221,1253 ----
FILE *aux_info_file;
FILE *rtl_dump_file = NULL;
+ /* Decode the string p as an integral parameter.
+ If the string is indeed an integer assign its numeric value into
+ the varibale pointed by valuep else issue an Invalid Option error
+ for the option pname. */
+
+ void
+ read_integral_parameter (p, valuep, pname)
+ char *p;
+ int *valuep;
+ char *pname;
+ {
+ char *endp = p;
+
+ while (*endp)
+ {
+ if (*endp >= '0' && *endp <= '9')
+ endp++;
+ else
+ {
+ error ("Invalid option `%s'", pname);
+ return;
+ }
+ }
+ *valuep = atoi (p);
+ }
+
+
/* Time accumulators, to count the total time spent in various passes. */
int parse_time;
Index: toplev.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/toplev.h,v
retrieving revision 1.14
diff -c -3 -p -r1.14 toplev.h
*** toplev.h 1999/01/06 20:10:39 1.14
--- toplev.h 1999/01/13 22:57:13
*************** union tree_node;
*** 26,31 ****
--- 26,32 ----
struct rtx_def;
#endif
+ extern void read_integral_parameter PROTO ((char *,int *,char *));
extern int count_error PROTO ((int));
extern void strip_off_ending PROTO ((char *, int));
extern void print_time PROTO ((char *, int));
Index: cp/ChangeLog
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/ChangeLog,v
retrieving revision 1.866
diff -c -3 -p -r1.866 ChangeLog
*** ChangeLog 1999/01/12 02:06:54 1.866
--- ChangeLog 1999/01/13 22:57:15
***************
*** 1,3 ****
--- 1,7 ----
+ 1999-01-08 Theodore Papadopoulo <Theodore.Papadopoulo@sophia.inria.fr>
+
+ * decl2.c (lang_decode_option): Use read_integral_parameter.
+
1999-01-12 Richard Henderson <rth@cygnus.com>
* cp-tree.h (flag_permissive): Declare extern.
Index: cp/decl2.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl2.c,v
retrieving revision 1.170
diff -c -3 -p -r1.170 decl2.c
*** decl2.c 1998/12/16 21:15:17 1.170
--- decl2.c 1999/01/13 22:57:21
*************** lang_decode_option (argc, argv)
*** 606,640 ****
}
else if (!strncmp (p, "template-depth-", 15))
{
! char *endp = p + 15;
! while (*endp)
! {
! if (*endp >= '0' && *endp <= '9')
! endp++;
! else
! {
! error ("Invalid option `%s'", p - 2);
! goto template_depth_lose;
! }
! }
! max_tinst_depth = atoi (p + 15);
! template_depth_lose: ;
}
else if (!strncmp (p, "name-mangling-version-", 22))
{
! char *endp = p + 22;
! while (*endp)
! {
! if (*endp >= '0' && *endp <= '9')
! endp++;
! else
! {
! error ("Invalid option `%s'", p - 2);
! goto mangling_version_lose;
! }
! }
! name_mangling_version = atoi (p + 22);
! mangling_version_lose: ;
}
else for (j = 0;
!found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]);
--- 606,616 ----
}
else if (!strncmp (p, "template-depth-", 15))
{
! read_integral_parameter (p + 15, &max_tinst_depth, p - 2);
}
else if (!strncmp (p, "name-mangling-version-", 22))
{
! read_integral_parameter (p + 22, &name_mangling_version, p-2);
}
else for (j = 0;
!found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]);
--------------------------------------------------------------------
Theodore Papadopoulo
Email: Theodore.Papadopoulo@sophia.inria.fr Tel: (33) 04 92 38 76 01
--------------------------------------------------------------------