diff options
Diffstat (limited to 'libgfortran/io/open.c')
-rw-r--r-- | libgfortran/io/open.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/libgfortran/io/open.c b/libgfortran/io/open.c index d7448c0..bcf7941 100644 --- a/libgfortran/io/open.c +++ b/libgfortran/io/open.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 +/* Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. Contributed by Andy Vaught F2003 I/O support contributed by Jerry DeLisle @@ -467,12 +467,8 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags * flags) break; opp->file = tmpname; -#ifdef HAVE_SNPRINTF opp->file_len = snprintf(opp->file, sizeof (tmpname), "fort.%d", (int) opp->common.unit); -#else - opp->file_len = sprintf(opp->file, "fort.%d", (int) opp->common.unit); -#endif break; default: @@ -504,26 +500,29 @@ new_unit (st_parameter_open *opp, gfc_unit *u, unit_flags * flags) if (s == NULL) { char *path, *msg; + size_t msglen; path = (char *) gfc_alloca (opp->file_len + 1); - msg = (char *) gfc_alloca (opp->file_len + 51); + msglen = opp->file_len + 51; + msg = (char *) gfc_alloca (msglen); unpack_filename (path, opp->file, opp->file_len); switch (errno) { case ENOENT: - sprintf (msg, "File '%s' does not exist", path); + snprintf (msg, msglen, "File '%s' does not exist", path); break; case EEXIST: - sprintf (msg, "File '%s' already exists", path); + snprintf (msg, msglen, "File '%s' already exists", path); break; case EACCES: - sprintf (msg, "Permission denied trying to open file '%s'", path); + snprintf (msg, msglen, + "Permission denied trying to open file '%s'", path); break; case EISDIR: - sprintf (msg, "'%s' is a directory", path); + snprintf (msg, msglen, "'%s' is a directory", path); break; default: |