diff options
Diffstat (limited to 'fluid/tools/ExternalCodeEditor_UNIX.cxx')
| -rw-r--r-- | fluid/tools/ExternalCodeEditor_UNIX.cxx | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/fluid/tools/ExternalCodeEditor_UNIX.cxx b/fluid/tools/ExternalCodeEditor_UNIX.cxx index 9e9ffd00e..60ed16814 100644 --- a/fluid/tools/ExternalCodeEditor_UNIX.cxx +++ b/fluid/tools/ExternalCodeEditor_UNIX.cxx @@ -27,7 +27,7 @@ using namespace fld; // Static local data static int L_editors_open = 0; // keep track of #editors open -static Fl_Timeout_Handler L_update_timer_cb = nullptr; // app's update timer callback +static Fl_Timeout_Handler L_update_timer_cb = 0; // app's update timer callback // [Static/Local] See if file exists static int is_file(const char *filename) { @@ -59,7 +59,7 @@ static int is_dir(const char *dirname) { */ ExternalCodeEditor::ExternalCodeEditor() { pid_ = -1; - filename_ = nullptr; + filename_ = 0; file_mtime_ = 0; file_size_ = 0; alert_pipe_[0] = alert_pipe_[1] = -1; @@ -75,7 +75,7 @@ ExternalCodeEditor::~ExternalCodeEditor() { printf("ExternalCodeEditor() DTOR CALLED (this=%p, pid=%ld)\n", (void*)this, (long)pid_); close_editor(); // close editor, delete tmp file - set_filename(nullptr); // free()s filename + set_filename(0); // free()s filename if (alert_pipe_open_) { Fl::remove_fd(alert_pipe_[0]); @@ -87,12 +87,12 @@ ExternalCodeEditor::~ExternalCodeEditor() { /** Set the filename for the file we wish to edit. Handles memory allocation/free. - If set to nullptr, frees memory. + If set to 0, frees memory. \param[in] val new filename */ void ExternalCodeEditor::set_filename(const char *val) { if ( filename_ ) free((void*)filename_); - filename_ = val ? fl_strdup(val) : nullptr; + filename_ = val ? fl_strdup(val) : 0; } /** @@ -121,7 +121,7 @@ void ExternalCodeEditor::close_editor() { switch ( fl_choice("Please close external editor\npid=%ld file=%s", "Force Close", // button 0 "Closed", // button 1 - nullptr, // button 2 + 0, // button 2 long(pid_), filename() ) ) { case 0: // Force Close kill_editor(); @@ -187,7 +187,7 @@ void ExternalCodeEditor::kill_editor() { \return -1 error getting file info (strerror() has reason) */ int ExternalCodeEditor::handle_changes(const char **code, int force) { - code[0] = nullptr; + code[0] = 0; if ( !is_editing() ) return 0; // Get current time/size info, see if file changed int changed = 0; @@ -247,7 +247,7 @@ int ExternalCodeEditor::remove_tmpfile() { return -1; } } - set_filename(nullptr); + set_filename(0); file_mtime_ = 0; file_size_ = 0; return 1; @@ -280,7 +280,7 @@ void ExternalCodeEditor::tmpdir_clear() { /** Creates temp dir (if doesn't exist) and returns the dirname as a static string. - \return nullptr on error, dialog shows reason. + \return 0 on error, dialog shows reason. */ const char* ExternalCodeEditor::create_tmpdir() { const char *dirname = tmpdir_name(); @@ -288,7 +288,7 @@ const char* ExternalCodeEditor::create_tmpdir() { if ( mkdir(dirname, 0777) < 0 ) { fl_alert("can't create directory '%s': %s", dirname, strerror(errno)); - return nullptr; + return 0; } } return dirname; @@ -296,13 +296,13 @@ const char* ExternalCodeEditor::create_tmpdir() { /** Returns temp filename in static buffer. - \return nullptr if can't, posts dialog explaining why. + \return 0 if can't, posts dialog explaining why. */ const char* ExternalCodeEditor::tmp_filename() { static char path[FL_PATH_MAX+1]; const char *tmpdir = create_tmpdir(); - if ( !tmpdir ) return nullptr; - const char *ext = Fluid.proj.code_file_name.c_str(); // e.g. ".cxx" + if ( !tmpdir ) return 0; + const char *ext = Fluid.proj.code_file_name(); // e.g. ".cxx" snprintf(path, FL_PATH_MAX, "%s/%p%s", tmpdir, (void*)this, ext); path[FL_PATH_MAX] = 0; return path; @@ -310,12 +310,12 @@ const char* ExternalCodeEditor::tmp_filename() { /** Save string 'code' to 'filename', returning file's mtime/size. - 'code' can be nullptr -- writes an empty file if so. + 'code' can be 0 -- writes an empty file if so. \return 0 on success \return -1 on error (posts dialog with reason) */ static int save_file(const char *filename, const char *code) { - if ( code == nullptr ) code = ""; // nullptr? write an empty file + if ( code == 0 ) code = ""; // 0? write an empty file int fd = open(filename, O_WRONLY|O_CREAT, 0666); if ( fd == -1 ) { fl_alert("ERROR: open() '%s': %s", filename, strerror(errno)); @@ -338,7 +338,7 @@ static int save_file(const char *filename, const char *code) { /** Convert string 's' to array of argv[], useful for execve(). - - 's' will be modified (words will be nullptr separated) + - 's' will be modified (words will be 0 separated) - argv[] will end up pointing to the words of 's' - Caller must free argv with: free(argv); \return -1 in case of memory allocation error @@ -348,14 +348,14 @@ static int make_args(char *s, // string containing words (gets trashed!) int *aargc, // pointer to argc char ***aargv) { // pointer to argv char *ss, **argv; - if ((argv=(char**)malloc(sizeof(char*) * (strlen(s)/2)))==nullptr) { + if ((argv=(char**)malloc(sizeof(char*) * (strlen(s)/2)))==0) { return -1; } int t; - for(t=0; (t==0)?(ss=strtok(s," \t")):(ss=strtok(nullptr," \t")); t++) { + for(t=0; (t==0)?(ss=strtok(s," \t")):(ss=strtok(0," \t")); t++) { argv[t] = ss; } - argv[t] = nullptr; + argv[t] = 0; aargv[0] = argv; aargc[0] = t; return(t); @@ -401,7 +401,7 @@ int ExternalCodeEditor::start_editor(const char *editor_cmd, // NOTE: no FLTK calls after a fork. Use a pipe to tell the app if the // command can't launch int nargs; - char **args = nullptr; + char **args = 0; if (make_args(cmd, &nargs, &args) > 0) { execvp(args[0], args); // run command - doesn't return if succeeds if (alert_pipe_open_) { @@ -428,7 +428,7 @@ int ExternalCodeEditor::start_editor(const char *editor_cmd, /** Try to reap external editor process. - If 'pid_reaped' not nullptr, returns PID of reaped editor. + If 'pid_reaped' not 0, returns PID of reaped editor. \return -2: editor not open \return -1: waitpid() failed (errno has reason) @@ -464,7 +464,7 @@ int ExternalCodeEditor::reap_editor(pid_t *pid_reaped) { Open external editor using 'editor_cmd' to edit 'code'. 'code' contains multiline code to be edited as a temp file. - 'code' can be nullptr -- edits an empty file if so. + 'code' can be 0 -- edits an empty file if so. \return 0 if succeeds \return -1 if can't open editor (already open, etc), |
