diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2003-10-24 15:02:42 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2003-10-24 15:02:42 +0200 |
commit | b0f26df5db7c471770e7219881e9bfe85cd3a039 (patch) | |
tree | 897ca34543cba57ab757439fcdd09dd83b34f5e6 /gcc/ada/adadecode.c | |
parent | bf22935f99c213b406b368ccdbff2572a8d08df0 (diff) | |
download | gcc-b0f26df5db7c471770e7219881e9bfe85cd3a039.zip gcc-b0f26df5db7c471770e7219881e9bfe85cd3a039.tar.gz gcc-b0f26df5db7c471770e7219881e9bfe85cd3a039.tar.bz2 |
re PR ada/12014 (strcpy used with overlapping arguments)
* adadecode.c (ostrcpy): New function.
(__gnat_decode): Use ostrcpy of strcpy.
(has_prefix): Set first parameter a const.
(has_suffix): Set first parameter a const.
Update copyright notice. Fix source name in header.
Removes a trailing space.
PR ada/12014.
* exp_disp.adb:
Remove the test against being in No_Run_Time_Mode before generating a
call to Register_Tag. It is redundant with the test against the
availability of the function Register_Tag.
* g-catiio.adb: (Month_Name): Correct spelling of February
* make.adb: (Mains): New package
(Initialize): Call Mains.Delete
(Gnatmake): Check that each main on the command line is a source of a
project file and, if there are several mains, each of them is a source
of the same project file.
(Gnatmake): When a foreign language is specified in attribute Languages,
no main is specified on the command line and attribute Mains is not
empty, only build the Ada main. If there is no Ada main, just compile
the Ada sources and their closure.
(Gnatmake): If a main is specified on the command line with directory
information, check that the source exists and, if it does, that the path
is the actual path of a source of a project.
* prj-env.adb:
(File_Name_Of_Library_Unit_Body): New Boolean parameter Full_Path. When
Full_Path is True, return the full path instead of the simple file name.
(Project_Of): New function
* prj-env.ads:
(File_Name_Of_Library_Unit_Body): New Boolean parameter Full_Path,
defaulted to False.
(Project_Of): New function
* Makefile.generic:
Ensure objects of main project are always checked and rebuilt if needed.
Set CC to gcc by default.
Prepare new handling of link by creating a global archive (not activated
yet).
* adadecode.h, atree.h, elists.h, nlists.h, raise.h,
stringt.h: Update copyright notice. Remove trailing blanks.
Fix source name in header.
* sem_ch12.adb: Minor reformatting
* sem_ch3.adb:
Minor reformatting (including new function return style throughout)
* sem_ch3.ads:
Minor reformatting (including new function return style throughout)
* Make-lang.in: Makefile automatically updated
From-SVN: r72893
Diffstat (limited to 'gcc/ada/adadecode.c')
-rw-r--r-- | gcc/ada/adadecode.c | 46 |
1 files changed, 30 insertions, 16 deletions
diff --git a/gcc/ada/adadecode.c b/gcc/ada/adadecode.c index 87eb3c3..928b838 100644 --- a/gcc/ada/adadecode.c +++ b/gcc/ada/adadecode.c @@ -2,11 +2,11 @@ * * * GNAT COMPILER COMPONENTS * * * - * G N A T D E C O * + * A D A D E C O D E * * * * C Implementation File * * * - * Copyright (C) 2001-2002, Free Software Foundation, Inc. * + * Copyright (C) 2001-2003, Free Software Foundation, Inc. * * * * GNAT is free software; you can redistribute it and/or modify it under * * terms of the GNU General Public License as published by the Free Soft- * @@ -42,8 +42,12 @@ #include "adadecode.h" static void add_verbose PARAMS ((const char *, char *)); -static int has_prefix PARAMS ((char *, const char *)); -static int has_suffix PARAMS ((char *, const char *)); +static int has_prefix PARAMS ((const char *, const char *)); +static int has_suffix PARAMS ((const char *, const char *)); + +/* This is a safe version of strcpy that can be used with overlapped + pointers. Does nothing if s2 <= s1. */ +static void ostrcpy (char *s1, char *s2); /* Set to nonzero if we have written any verbose info. */ static int verbose_info; @@ -65,7 +69,7 @@ static void add_verbose (text, ada_name) static int has_prefix (name, prefix) - char *name; + const char *name; const char *prefix; { return strncmp (name, prefix, strlen (prefix)) == 0; @@ -75,7 +79,7 @@ has_prefix (name, prefix) static int has_suffix (name, suffix) - char *name; + const char *name; const char *suffix; { int nlen = strlen (name); @@ -84,6 +88,18 @@ has_suffix (name, suffix) return nlen > slen && strncmp (name + nlen - slen, suffix, slen) == 0; } +/* Safe overlapped pointers version of strcpy. */ + +static void +ostrcpy (char *s1, char *s2) +{ + if (s2 > s1) + { + while (*s2) *s1++ = *s2++; + *s1 = '\0'; + } +} + /* This function will return the Ada name from the encoded form. The Ada coding is done in exp_dbug.ads and this is the inverse function. see exp_dbug.ads for full encoding rules, a short description is added @@ -142,16 +158,14 @@ __gnat_decode (coded_name, ada_name, verbose) int in_task = 0; int body_nested = 0; - /* Copy the coded name into the ada name string, the rest of the code will - just replace or add characters into the ada_name. */ - strcpy (ada_name, coded_name); - /* Check for library level subprogram. */ - if (has_prefix (ada_name, "_ada_")) + if (has_prefix (coded_name, "_ada_")) { - strcpy (ada_name, ada_name + 5); + strcpy (ada_name, coded_name + 5); lib_subprog = 1; } + else + strcpy (ada_name, coded_name); /* Check for task body. */ if (has_suffix (ada_name, "TKB")) @@ -191,7 +205,7 @@ __gnat_decode (coded_name, ada_name, verbose) while ((tktoken = (char *) strstr (ada_name, "TK__")) != NULL) { - strcpy (tktoken, tktoken + 2); + ostrcpy (tktoken, tktoken + 2); in_task = 1; } } @@ -229,7 +243,7 @@ __gnat_decode (coded_name, ada_name, verbose) if (ada_name[k] == '_' && ada_name[k+1] == '_') { ada_name[k] = '.'; - strcpy (ada_name + k + 1, ada_name + k + 2); + ostrcpy (ada_name + k + 1, ada_name + k + 2); len = len - 1; } k++; @@ -259,7 +273,7 @@ __gnat_decode (coded_name, ada_name, verbose) if (codedlen > oplen) /* We shrink the space. */ - strcpy (optoken, optoken + codedlen - oplen); + ostrcpy (optoken, optoken + codedlen - oplen); else if (oplen > codedlen) { /* We need more space. */ @@ -285,7 +299,7 @@ __gnat_decode (coded_name, ada_name, verbose) } /* If verbose mode is on, we add some information to the Ada name. */ - if (verbose) + if (verbose) { if (overloaded) add_verbose ("overloaded", ada_name); |