system() patch for Win32

Started by Bruce Momjianover 23 years ago3 messagespatches
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Here is a patch to handle 'rm', 'cp', and 'exec' usage by system();
again very small.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Attachments:

/pgpatches/win32/systemtext/plainDownload+18-10
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#1)
Re: system() patch for Win32

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Here is a patch to handle 'rm', 'cp', and 'exec' usage by system();
again very small.

This part seems unnecessarily obscurantist:

! #ifndef WIN32
! #define EXEC "exec "
! #else
! #define EXEC ""
! #endif

! sprintf(sys, "%s%s '%s'", EXEC, editorName, fname);

I like the other style (just #ifdef to choose one of two sprintf
commands) better. It seems easier to understand, as well as less
fragile --- the way you have it here makes it *real* easy to break
the computation of the buffer size for the command string.

regards, tom lane

#3Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
Re: system() patch for Win32

OK, I have modified the use of "exec" to be more local to the snprintf.

---------------------------------------------------------------------------

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Here is a patch to handle 'rm', 'cp', and 'exec' usage by system();
again very small.

This part seems unnecessarily obscurantist:

! #ifndef WIN32
! #define EXEC "exec "
! #else
! #define EXEC ""
! #endif

! sprintf(sys, "%s%s '%s'", EXEC, editorName, fname);

I like the other style (just #ifdef to choose one of two sprintf
commands) better. It seems easier to understand, as well as less
fragile --- the way you have it here makes it *real* easy to break
the computation of the buffer size for the command string.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Attachments:

/pgpatches/win32/systemtext/plainDownload+20-14