From: Eli Zaretskii Date: Fri, 26 Dec 2014 09:52:24 +0000 (+0200) Subject: MS-Windows followup to stpcpy changes. X-Git-Tag: emacs-25.0.90~2634^2~2 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=d65526283d517e0b97b0c74af75bb2e869db4dae;p=emacs.git MS-Windows followup to stpcpy changes. src/w32proc.c (sys_spawnve, get_lcid_callback): Use strcpy instead of strcat. src/w32menu.c (add_menu_item): Use stpcpy instead of strcat. src/w32.c (sys_readdir, stat_worker, symlink): Use strcpy instead of strcat. nt/gnulib.mk (stpcpy, string): Sync with the latest change in lib/gnulib.mk. --- diff --git a/nt/ChangeLog b/nt/ChangeLog index 1edfda0ffd2..2467e64bbef 100644 --- a/nt/ChangeLog +++ b/nt/ChangeLog @@ -1,3 +1,8 @@ +2014-12-26 Eli Zaretskii + + * gnulib.mk (stpcpy, string): Sync with the latest change in + lib/gnulib.mk. + 2014-12-13 Eli Zaretskii * gnulib.mk (stddef.h): Sync with the latest change in lib/gnulib.mk. diff --git a/nt/gnulib.mk b/nt/gnulib.mk index 273f52293cc..a5dca96850f 100644 --- a/nt/gnulib.mk +++ b/nt/gnulib.mk @@ -43,7 +43,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub unsetenv update-copyright utimens vla warnings +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=close --avoid=dup --avoid=fchdir --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=open --avoid=openat-die --avoid=opendir --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=stdarg --avoid=stdbool --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt binary-io byteswap c-ctype c-strcase careadlinkat close-stream count-one-bits count-trailing-zeros crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl fcntl-h fdatasync fdopendir filemode fstatat fsync getloadavg getopt-gnu gettime gettimeofday intprops largefile lstat manywarnings memrchr mkostemp mktime pipe2 pselect pthread_sigmask putenv qacl readlink readlinkat sig2str socklen stat-time stdalign stddef stdio stpcpy strftime strtoimax strtoumax symlink sys_stat sys_time time time_r timer-time timespec-add timespec-sub unsetenv update-copyright utimens vla warnings MOSTLYCLEANFILES += core *.stackdump @@ -771,6 +771,15 @@ EXTRA_DIST += stdint.in.h ## end gnulib module stdint +## begin gnulib module stpcpy + + +EXTRA_DIST += stpcpy.c + +EXTRA_libgnu_a_SOURCES += stpcpy.c + +## end gnulib module stpcpy + ## begin gnulib module strftime libgnu_a_SOURCES += strftime.c @@ -779,6 +788,106 @@ EXTRA_DIST += strftime.h ## end gnulib module strftime +## begin gnulib module string + +BUILT_SOURCES += string.h + +# We need the following in order to create when the system +# doesn't have one that works with the given compiler. +string.h: string.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) + $(AM_V_GEN)rm -f $@-t $@ && \ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \ + sed -e 's|@''GUARD_PREFIX''@|GL|g' \ + -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \ + -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \ + -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ + -e 's|@''NEXT_STRING_H''@|$(NEXT_STRING_H)|g' \ + -e 's/@''GNULIB_FFSL''@/$(GNULIB_FFSL)/g' \ + -e 's/@''GNULIB_FFSLL''@/$(GNULIB_FFSLL)/g' \ + -e 's/@''GNULIB_MBSLEN''@/$(GNULIB_MBSLEN)/g' \ + -e 's/@''GNULIB_MBSNLEN''@/$(GNULIB_MBSNLEN)/g' \ + -e 's/@''GNULIB_MBSCHR''@/$(GNULIB_MBSCHR)/g' \ + -e 's/@''GNULIB_MBSRCHR''@/$(GNULIB_MBSRCHR)/g' \ + -e 's/@''GNULIB_MBSSTR''@/$(GNULIB_MBSSTR)/g' \ + -e 's/@''GNULIB_MBSCASECMP''@/$(GNULIB_MBSCASECMP)/g' \ + -e 's/@''GNULIB_MBSNCASECMP''@/$(GNULIB_MBSNCASECMP)/g' \ + -e 's/@''GNULIB_MBSPCASECMP''@/$(GNULIB_MBSPCASECMP)/g' \ + -e 's/@''GNULIB_MBSCASESTR''@/$(GNULIB_MBSCASESTR)/g' \ + -e 's/@''GNULIB_MBSCSPN''@/$(GNULIB_MBSCSPN)/g' \ + -e 's/@''GNULIB_MBSPBRK''@/$(GNULIB_MBSPBRK)/g' \ + -e 's/@''GNULIB_MBSSPN''@/$(GNULIB_MBSSPN)/g' \ + -e 's/@''GNULIB_MBSSEP''@/$(GNULIB_MBSSEP)/g' \ + -e 's/@''GNULIB_MBSTOK_R''@/$(GNULIB_MBSTOK_R)/g' \ + -e 's/@''GNULIB_MEMCHR''@/$(GNULIB_MEMCHR)/g' \ + -e 's/@''GNULIB_MEMMEM''@/$(GNULIB_MEMMEM)/g' \ + -e 's/@''GNULIB_MEMPCPY''@/$(GNULIB_MEMPCPY)/g' \ + -e 's/@''GNULIB_MEMRCHR''@/$(GNULIB_MEMRCHR)/g' \ + -e 's/@''GNULIB_RAWMEMCHR''@/$(GNULIB_RAWMEMCHR)/g' \ + -e 's/@''GNULIB_STPCPY''@/$(GNULIB_STPCPY)/g' \ + -e 's/@''GNULIB_STPNCPY''@/$(GNULIB_STPNCPY)/g' \ + -e 's/@''GNULIB_STRCHRNUL''@/$(GNULIB_STRCHRNUL)/g' \ + -e 's/@''GNULIB_STRDUP''@/$(GNULIB_STRDUP)/g' \ + -e 's/@''GNULIB_STRNCAT''@/$(GNULIB_STRNCAT)/g' \ + -e 's/@''GNULIB_STRNDUP''@/$(GNULIB_STRNDUP)/g' \ + -e 's/@''GNULIB_STRNLEN''@/$(GNULIB_STRNLEN)/g' \ + -e 's/@''GNULIB_STRPBRK''@/$(GNULIB_STRPBRK)/g' \ + -e 's/@''GNULIB_STRSEP''@/$(GNULIB_STRSEP)/g' \ + -e 's/@''GNULIB_STRSTR''@/$(GNULIB_STRSTR)/g' \ + -e 's/@''GNULIB_STRCASESTR''@/$(GNULIB_STRCASESTR)/g' \ + -e 's/@''GNULIB_STRTOK_R''@/$(GNULIB_STRTOK_R)/g' \ + -e 's/@''GNULIB_STRERROR''@/$(GNULIB_STRERROR)/g' \ + -e 's/@''GNULIB_STRERROR_R''@/$(GNULIB_STRERROR_R)/g' \ + -e 's/@''GNULIB_STRSIGNAL''@/$(GNULIB_STRSIGNAL)/g' \ + -e 's/@''GNULIB_STRVERSCMP''@/$(GNULIB_STRVERSCMP)/g' \ + < $(srcdir)/string.in.h | \ + sed -e 's|@''HAVE_FFSL''@|$(HAVE_FFSL)|g' \ + -e 's|@''HAVE_FFSLL''@|$(HAVE_FFSLL)|g' \ + -e 's|@''HAVE_MBSLEN''@|$(HAVE_MBSLEN)|g' \ + -e 's|@''HAVE_MEMCHR''@|$(HAVE_MEMCHR)|g' \ + -e 's|@''HAVE_DECL_MEMMEM''@|$(HAVE_DECL_MEMMEM)|g' \ + -e 's|@''HAVE_MEMPCPY''@|$(HAVE_MEMPCPY)|g' \ + -e 's|@''HAVE_DECL_MEMRCHR''@|$(HAVE_DECL_MEMRCHR)|g' \ + -e 's|@''HAVE_RAWMEMCHR''@|$(HAVE_RAWMEMCHR)|g' \ + -e 's|@''HAVE_STPCPY''@|$(HAVE_STPCPY)|g' \ + -e 's|@''HAVE_STPNCPY''@|$(HAVE_STPNCPY)|g' \ + -e 's|@''HAVE_STRCHRNUL''@|$(HAVE_STRCHRNUL)|g' \ + -e 's|@''HAVE_DECL_STRDUP''@|$(HAVE_DECL_STRDUP)|g' \ + -e 's|@''HAVE_DECL_STRNDUP''@|$(HAVE_DECL_STRNDUP)|g' \ + -e 's|@''HAVE_DECL_STRNLEN''@|$(HAVE_DECL_STRNLEN)|g' \ + -e 's|@''HAVE_STRPBRK''@|$(HAVE_STRPBRK)|g' \ + -e 's|@''HAVE_STRSEP''@|$(HAVE_STRSEP)|g' \ + -e 's|@''HAVE_STRCASESTR''@|$(HAVE_STRCASESTR)|g' \ + -e 's|@''HAVE_DECL_STRTOK_R''@|$(HAVE_DECL_STRTOK_R)|g' \ + -e 's|@''HAVE_DECL_STRERROR_R''@|$(HAVE_DECL_STRERROR_R)|g' \ + -e 's|@''HAVE_DECL_STRSIGNAL''@|$(HAVE_DECL_STRSIGNAL)|g' \ + -e 's|@''HAVE_STRVERSCMP''@|$(HAVE_STRVERSCMP)|g' \ + -e 's|@''REPLACE_STPNCPY''@|$(REPLACE_STPNCPY)|g' \ + -e 's|@''REPLACE_MEMCHR''@|$(REPLACE_MEMCHR)|g' \ + -e 's|@''REPLACE_MEMMEM''@|$(REPLACE_MEMMEM)|g' \ + -e 's|@''REPLACE_STRCASESTR''@|$(REPLACE_STRCASESTR)|g' \ + -e 's|@''REPLACE_STRCHRNUL''@|$(REPLACE_STRCHRNUL)|g' \ + -e 's|@''REPLACE_STRDUP''@|$(REPLACE_STRDUP)|g' \ + -e 's|@''REPLACE_STRSTR''@|$(REPLACE_STRSTR)|g' \ + -e 's|@''REPLACE_STRERROR''@|$(REPLACE_STRERROR)|g' \ + -e 's|@''REPLACE_STRERROR_R''@|$(REPLACE_STRERROR_R)|g' \ + -e 's|@''REPLACE_STRNCAT''@|$(REPLACE_STRNCAT)|g' \ + -e 's|@''REPLACE_STRNDUP''@|$(REPLACE_STRNDUP)|g' \ + -e 's|@''REPLACE_STRNLEN''@|$(REPLACE_STRNLEN)|g' \ + -e 's|@''REPLACE_STRSIGNAL''@|$(REPLACE_STRSIGNAL)|g' \ + -e 's|@''REPLACE_STRTOK_R''@|$(REPLACE_STRTOK_R)|g' \ + -e 's|@''UNDEFINE_STRTOK_R''@|$(UNDEFINE_STRTOK_R)|g' \ + -e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \ + -e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \ + -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)'; \ + < $(srcdir)/string.in.h; \ + } > $@-t && \ + mv $@-t $@ +MOSTLYCLEANFILES += string.h string.h-t + +EXTRA_DIST += string.in.h + +## end gnulib module string + ## begin gnulib module strtoimax diff --git a/src/ChangeLog b/src/ChangeLog index f3bc9fd2c87..72601fe7c58 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,13 @@ +2014-12-26 Eli Zaretskii + + * w32proc.c (sys_spawnve, get_lcid_callback): Use strcpy instead + of strcat. + + * w32menu.c (add_menu_item): Use stpcpy instead of strcat. + + * w32.c (sys_readdir, stat_worker, symlink): Use strcpy instead of + strcat. + 2014-12-26 Paul Eggert Use bool for boolean in xsmfns.c diff --git a/src/w32.c b/src/w32.c index 8d8f536ca40..6dea0c2a811 100644 --- a/src/w32.c +++ b/src/w32.c @@ -3405,10 +3405,10 @@ sys_readdir (DIR *dirp) int ln; strcpy (filename, dir_pathname); - ln = strlen (filename) - 1; - if (!IS_DIRECTORY_SEP (filename[ln])) - strcat (filename, "\\"); - strcat (filename, "*"); + ln = strlen (filename); + if (!IS_DIRECTORY_SEP (filename[ln - 1])) + filename[ln++] = '\\'; + strcpy (filename + ln, "*"); /* Note: No need to resolve symlinks in FILENAME, because FindFirst opens the directory that is the target of a @@ -4969,7 +4969,7 @@ stat_worker (const char * path, struct stat * buf, int follow_symlinks) { /* Make sure root directories end in a slash. */ if (!IS_DIRECTORY_SEP (name[len-1])) - strcat (name, "\\"); + strcpy (name + len, "\\"); if (GetDriveType (name) < 2) { errno = ENOENT; @@ -5438,8 +5438,7 @@ symlink (char const *filename, char const *linkname) p--; if (p > linkfn) strncpy (tem, linkfn, p - linkfn); - tem[p - linkfn] = '\0'; - strcat (tem, filename); + strcpy (tem + (p - linkfn), filename); dir_access = faccessat (AT_FDCWD, tem, D_OK, AT_EACCESS); } else diff --git a/src/w32menu.c b/src/w32menu.c index 6633ffddbcf..287062c702c 100644 --- a/src/w32menu.c +++ b/src/w32menu.c @@ -1256,9 +1256,9 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item) if (wv->key != NULL) { out_string = SAFE_ALLOCA (strlen (wv->name) + strlen (wv->key) + 2); - strcpy (out_string, wv->name); - strcat (out_string, "\t"); - strcat (out_string, wv->key); + p = stpcpy (out_string, wv->name); + p = stpcpy (p, "\t"); + strcpy (p, wv->key); } else out_string = (char *)wv->name; diff --git a/src/w32proc.c b/src/w32proc.c index 09e0c0530a4..c571726d70f 100644 --- a/src/w32proc.c +++ b/src/w32proc.c @@ -1665,10 +1665,7 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp) if (egetenv ("CMDPROXY")) strcpy (cmdname, egetenv ("CMDPROXY")); else - { - lispstpcpy (cmdname, Vinvocation_directory); - strcat (cmdname, "cmdproxy.exe"); - } + strcpy (lispstpcpy (cmdname, Vinvocation_directory), "cmdproxy.exe"); /* Can't use unixtodos_filename here, since that needs its file name argument encoded in UTF-8. */ @@ -3183,18 +3180,20 @@ get_lcid_callback (LPTSTR locale_num_str) if (GetLocaleInfo (try_lcid, LOCALE_SABBREVLANGNAME, locval, LOCALE_NAME_MAX_LENGTH)) { + size_t locval_len; + /* This is for when they only specify the language, as in "ENU". */ if (stricmp (locval, lname) == 0) { found_lcid = try_lcid; return FALSE; } - strcat (locval, "_"); + locval_len = strlen (locval); + strcpy (locval + locval_len, "_"); if (GetLocaleInfo (try_lcid, LOCALE_SABBREVCTRYNAME, - locval + strlen (locval), LOCALE_NAME_MAX_LENGTH)) + locval + locval_len + 1, LOCALE_NAME_MAX_LENGTH)) { - size_t locval_len = strlen (locval); - + locval_len = strlen (locval); if (strnicmp (locval, lname, locval_len) == 0 && (lname[locval_len] == '.' || lname[locval_len] == '\0'))