diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2017-10-13 14:58:30 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2017-10-13 14:58:30 +0000 |
| commit | 66b1690aa8b5d05f540ded9999c08525cd1eaf7a (patch) | |
| tree | ccb5a3a743f1e008fd4b217c619ba99faee62612 | |
| parent | db83933f585d156db2ae35d9c5649bb21b4555af (diff) | |
Replace remaining calls to getenv() with fl_getenv().
... except in driver code that uses Fl_System_Driver::getenv().
Todo: Check if all remaining calls of getenv() in driver code are correct
or might use ::getenv() to avoid one calling level for optimization.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12492 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
| -rw-r--r-- | examples/nativefilechooser-simple-app.cxx | 10 | ||||
| -rw-r--r-- | fluid/fluid.cxx | 4 | ||||
| -rw-r--r-- | src/Fl_File_Icon2.cxx | 3 | ||||
| -rw-r--r-- | src/fl_utf8.cxx | 18 | ||||
| -rw-r--r-- | src/print_panel.cxx | 4 | ||||
| -rw-r--r-- | test/checkers.cxx | 4 | ||||
| -rw-r--r-- | test/file_chooser.cxx | 3 |
7 files changed, 30 insertions, 16 deletions
diff --git a/examples/nativefilechooser-simple-app.cxx b/examples/nativefilechooser-simple-app.cxx index cb35bcfd6..d206daeac 100644 --- a/examples/nativefilechooser-simple-app.cxx +++ b/examples/nativefilechooser-simple-app.cxx @@ -4,7 +4,7 @@ // An example of how to use Fl_Native_File_Chooser to open & save files. // // Copyright 2010 Greg Ercolano. -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -46,7 +46,7 @@ class Application : public Fl_Window { void save(const char *filename) { printf("Saving '%s'\n", filename); if ( !exist(filename) ) { - FILE *fp = fl_fopen(filename, "w"); // create file if it doesn't exist + FILE *fp = fl_fopen(filename, "w"); // create file if it doesn't exist if ( fp ) { // A real app would do something useful here. fprintf(fp, "Hello world.\n"); @@ -103,9 +103,9 @@ class Application : public Fl_Window { static char *filename = 0; if ( !filename ) { const char *home = - getenv("HOME") ? getenv("HOME") : // unix - getenv("HOME_PATH") ? getenv("HOME_PATH") : // windows - "."; // other + fl_getenv("HOME") ? fl_getenv("HOME") : // unix + fl_getenv("HOME_PATH") ? fl_getenv("HOME_PATH") : // windows + "."; // other filename = (char*)malloc(strlen(home)+20); sprintf(filename, "%s/untitled.txt", home); } diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx index 8820da19b..5d65942a6 100644 --- a/fluid/fluid.cxx +++ b/fluid/fluid.cxx @@ -3,7 +3,7 @@ // // FLUID main entry for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2016 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -899,7 +899,7 @@ void show_help(const char *name) { if (!help_dialog) help_dialog = new Fl_Help_Dialog(); - if ((docdir = getenv("FLTK_DOCDIR")) == NULL) { + if ((docdir = fl_getenv("FLTK_DOCDIR")) == NULL) { docdir = FLTK_DOCDIR; } snprintf(helpname, sizeof(helpname), "%s/%s", docdir, name); diff --git a/src/Fl_File_Icon2.cxx b/src/Fl_File_Icon2.cxx index 3bd0b9189..9022423b0 100644 --- a/src/Fl_File_Icon2.cxx +++ b/src/Fl_File_Icon2.cxx @@ -6,6 +6,7 @@ // KDE icon code donated by Maarten De Boer. // // Copyright 1999-2010 by Michael Sweet. +// Copyright 2011-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -653,7 +654,7 @@ Fl_File_Icon::load_system_icons(void) { if (!kdedir) { // Figure out where KDE is installed... - if ((kdedir = getenv("KDEDIR")) == NULL) { + if ((kdedir = fl_getenv("KDEDIR")) == NULL) { if (!fl_access("/opt/kde", F_OK)) kdedir = "/opt/kde"; else if (!fl_access("/usr/local/share/mimelnk", F_OK)) kdedir = "/usr/local"; else kdedir = "/usr"; diff --git a/src/fl_utf8.cxx b/src/fl_utf8.cxx index afd5c6005..0a79e5867 100644 --- a/src/fl_utf8.cxx +++ b/src/fl_utf8.cxx @@ -5,7 +5,7 @@ // // Author: Jean-Marc Lienher ( http://oksid.ch ) // Copyright 2000-2010 by O'ksi'D. -// Copyright 2016 by Bill Spitzak and others. +// Copyright 2016-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -286,13 +286,25 @@ char * fl_utf2mbcs(const char *s) /** Cross-platform function to get environment variables with a UTF-8 encoded name or value. - This function is especially useful under the MSWindows platform where + This function is especially useful under the Windows platform where non-ASCII environment variables are encoded as wide characters. The returned value of the variable is encoded in UTF-8 as well. - On platforms other than MSWindows this function calls getenv directly. + On platforms other than Windows this function calls getenv directly. The return value is returned as-is. + The return value is a pointer to an implementation defined buffer: + - an internal buffer that is (re)allocated as needed (Windows) or + - the string in the environment itself (Unix, Linux, MaOS) or + - any other implementation (other platforms). + This string must be considered read-only and must not be freed by the caller. + + If the resultant string is to be used later it must be copied to a safe + place. The next call to fl_getenv() or any other environment changes may + overwrite the string. + + \note This function is not thread-safe. + \param[in] v the UTF-8 encoded environment variable \return the environment variable in UTF-8 encoding, or NULL in case of error. */ diff --git a/src/print_panel.cxx b/src/print_panel.cxx index 18bc2982c..4508c9c23 100644 --- a/src/print_panel.cxx +++ b/src/print_panel.cxx @@ -3,7 +3,7 @@ // // Print panel for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -565,7 +565,7 @@ printing_style print_load() { // return whether SystemV or BSD printing style is } } fclose(lpstat); - p = getenv("PRINTER"); // get name of default printer + p = fl_getenv("PRINTER"); // get name of default printer if (p == NULL) p = (char*)"lp"; strcpy(defname, p); } diff --git a/test/checkers.cxx b/test/checkers.cxx index b9adf95b2..0a0972ada 100644 --- a/test/checkers.cxx +++ b/test/checkers.cxx @@ -6,7 +6,7 @@ // Hours of fun: the FLTK checkers game! // Based on a very old algorithm, but it still works! // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -1346,7 +1346,7 @@ int main(int argc, char **argv) { fprintf(stderr," -t : use VT100 display\n", Fl::help); exit(1); } - if (!getenv("DISPLAY")) terminal = 1; + if (!fl_getenv("DISPLAY")) terminal = 1; if (!terminal) #endif #ifdef FLTK diff --git a/test/file_chooser.cxx b/test/file_chooser.cxx index f099b8c78..12f43f0c1 100644 --- a/test/file_chooser.cxx +++ b/test/file_chooser.cxx @@ -4,6 +4,7 @@ // File chooser test program. // // Copyright 1999-2010 by Michael Sweet. +// Copyright 2011-2017 by Bill Spitzak and others. // // This library is free software. Distribution and use rights are outlined in // the file "COPYING" which should have been included with this file. If this @@ -256,7 +257,7 @@ pdf_check(const char *name, // I - Name of file if (memcmp(header, "%PDF", 4) != 0) return 0; - home = getenv("HOME"); + home = fl_getenv("HOME"); sprintf(preview, "%s/.preview.ppm", home ? home : ""); sprintf(command, |
