Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #385653
| From | Keith Thompson <Keith.S.Thompson+u@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Running an editor from ANSI C |
| Date | 2024-06-06 15:55 -0700 |
| Organization | None to speak of |
| Message-ID | <87frtpznoa.fsf@nosuchdomain.example.com> (permalink) |
| References | (3 earlier) <v3rek5$1c4i5$1@dont-email.me> <v3rrtm$1e6g8$1@dont-email.me> <v3ru84$1eafb$1@dont-email.me> <87o78dzw1a.fsf@nosuchdomain.example.com> <v3te2i$1ms1q$1@dont-email.me> |
Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
> On 06/06/2024 20:54, Keith Thompson wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>> On 06/06/2024 10:27, Malcolm McLean wrote:
>>>> It does work. But my compiler warns about rmpnam() being deprecated.
>>>
>>> I presume you mean "tmpnam()" here. No, it has not been deprecated -
>>> not even in C23. I could be wrong, but this sounds like one of MSVC's
>>> arbitrary self-declared deprecations, using scare tactics to encourage
>>> people to use MSVC's own functions rather than standard C functions,
>>> thus locking you into their tools and platform.
>> [...]
>> You're right, tmpnam() is not deprecated either by ISO C or by
>> POSIX.
>> But tmpfile() is likely to be better for most purposes. It creates
>> a
>> file and returns a FILE*. tmpnam() returns a string pointer, and it's
>> possible that some other process could create a file with the same name
>> before the caller has a chance to create it.
>> (mkstemp() is more flexible, but is not defined by ISO C.)
>>
> I want to run nano (or vi, or ed), in a shell running a pure ansi C
> program. So the way to do it is to create a file, write the text you
> want edit to it, them call system("nano readme.txt"). Nano then grabs
> the cobsole, which is what you want. You then read the file to get
> the edited data.
>
> The shell isn't just a proof og concept. It has a practical purpose,
> because it is FileSystem XML file editor. Whilst I'm playing about
> putting Basic into it for fun, the real purpose is serious. And the
> user must have an easy way of editing text files in the FileSystem
> file.
>
> But it becomes effectively a virtual computer in its own right.
OK -- but that has nothing at all to do with my post, which was about
how to generate the temporary file name.
One suggestion: rather than always using nano (which not everyone is
familiar with), try reading the $EDITOR environment variable to
determine what editor to use. Concatenating the value of
getenv("EDITOR"), followed by a space, followed by the file name, is
likely to give you a valid command you can pass to system(). Fall back
to nano if getenv("EDITOR") returns a null pointer.
(For historical reasons, the convention is to use $VISUAL if it's set,
otherwise $EDITOR if it's set, otherwise some default. Originally
$VISUAL typically referred to a full-screen editor like vi and $EDITOR
to a line editor like ed, to be used when full-screen editing is not
available. That's unlikely to be relevant nowadays, and users typically
either don't set $VISUAL or set it to the same thing as $EDITOR.)
Don't do this for me; I'm not likely to use this. But others are likely
to find it more user-friendly if they can use a chosen editor.
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
void Void(void) { Void(); } /* The recursive call of the void */
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar
Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-05 11:59 +0100
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-06 01:18 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-06 03:47 +0100
Re: Running an editor from ANSI C Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-06 06:40 +0200
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-06 04:47 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-06 09:27 +0100
Re: Running an editor from ANSI C David Brown <david.brown@hesbynett.no> - 2024-06-06 11:07 +0200
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-06 14:34 +0100
Re: Running an editor from ANSI C scott@slp53.sl.home (Scott Lurndal) - 2024-06-06 13:54 +0000
Re: Running an editor from ANSI C Richard Harnden <richard.nospam@gmail.invalid> - 2024-06-06 15:13 +0100
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-06 15:35 +0100
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-07 00:40 +0000
Re: Running an editor from ANSI C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-06 12:54 -0700
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-06 23:43 +0100
Re: Running an editor from ANSI C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-06 15:55 -0700
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-07 10:08 +0100
Re: Running an editor from ANSI C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-07 02:37 -0700
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-07 10:47 +0000
Re: Running an editor from ANSI C Michael S <already5chosen@yahoo.com> - 2024-06-07 14:24 +0300
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-07 23:57 +0000
Re: Running an editor from ANSI C Michael S <already5chosen@yahoo.com> - 2024-06-08 22:13 +0300
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-08 22:06 +0100
Re: Running an editor from ANSI C scott@slp53.sl.home (Scott Lurndal) - 2024-06-09 14:28 +0000
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-09 07:24 +0000
Re: Running an editor from ANSI C Michael S <already5chosen@yahoo.com> - 2024-06-09 11:36 +0300
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-09 22:29 +0000
Re: Running an editor from ANSI C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-08 13:51 -0700
Re: Running an editor from ANSI C Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-09 00:27 +0000
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-09 07:30 +0000
Re: Running an editor from ANSI C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-09 14:48 -0700
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-09 07:29 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-07 13:57 +0100
Re: Running an editor from ANSI C Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2024-06-07 19:56 +0200
Re: Running an editor from ANSI C scott@slp53.sl.home (Scott Lurndal) - 2024-06-07 18:10 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-07 19:52 +0100
Re: Running an editor from ANSI C Richard Harnden <richard.nospam@gmail.invalid> - 2024-06-07 20:08 +0100
Re: Running an editor from ANSI C Ben Bacarisse <ben@bsb.me.uk> - 2024-06-07 20:09 +0100
Re: Running an editor from ANSI C Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-07 20:37 +0000
Re: Running an editor from ANSI C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-07 12:39 -0700
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-08 00:34 +0000
Re: Running an editor from ANSI C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-07 23:35 -0700
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-08 08:24 +0000
Re: Running an editor from ANSI C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-10 13:28 -0700
Re: Running an editor from ANSI C scott@slp53.sl.home (Scott Lurndal) - 2024-06-07 14:02 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-07 20:06 +0100
Re: Running an editor from ANSI C scott@slp53.sl.home (Scott Lurndal) - 2024-06-07 20:06 +0000
Re: Running an editor from ANSI C Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-07 04:46 +0000
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-07 00:36 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-07 10:13 +0100
Re: Running an editor from ANSI C David Brown <david.brown@hesbynett.no> - 2024-06-07 11:31 +0200
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-07 10:46 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-07 13:47 +0100
Re: Running an editor from ANSI C James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-06-07 09:32 -0400
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-07 23:59 +0000
Re: Running an editor from ANSI C James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-06-08 01:40 -0400
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-08 08:21 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-08 13:43 +0100
Re: Running an editor from ANSI C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2024-06-08 12:00 -0700
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-09 03:30 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-08 12:32 +0100
Re: Running an editor from ANSI C David Brown <david.brown@hesbynett.no> - 2024-06-07 16:48 +0200
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-07 19:38 +0100
Re: Running an editor from ANSI C scott@slp53.sl.home (Scott Lurndal) - 2024-06-07 20:04 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-08 00:00 +0100
Re: Running an editor from ANSI C Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-08 00:36 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-08 12:07 +0100
Re: Running an editor from ANSI C James Kuyper <jameskuyper@alumni.caltech.edu> - 2024-06-08 01:54 -0400
Re: Running an editor from ANSI C Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-08 00:32 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-08 12:23 +0100
Re: Running an editor from ANSI C Kaz Kylheku <643-408-1753@kylheku.com> - 2024-06-08 18:07 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-08 22:01 +0100
Re: Running an editor from ANSI C David Brown <david.brown@hesbynett.no> - 2024-06-09 17:49 +0200
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-10 12:31 +0100
Re: Running an editor from ANSI C David Brown <david.brown@hesbynett.no> - 2024-06-10 14:12 +0200
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-10 14:19 +0100
Re: Running an editor from ANSI C Richard Harnden <richard.nospam@gmail.invalid> - 2024-06-10 18:14 +0100
Re: Running an editor from ANSI C scott@slp53.sl.home (Scott Lurndal) - 2024-06-10 17:37 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-11 05:24 +0100
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-11 05:52 +0000
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-12 09:08 +0100
Re: Running an editor from ANSI C David Brown <david.brown@hesbynett.no> - 2024-06-12 11:00 +0200
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-12 10:57 +0100
Re: Running an editor from ANSI C Richard Harnden <richard.nospam@gmail.invalid> - 2024-06-12 13:43 +0100
Re: Running an editor from ANSI C David Brown <david.brown@hesbynett.no> - 2024-06-12 14:54 +0200
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-12 15:42 +0100
Re: Running an editor from ANSI C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2024-06-12 14:34 -0700
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-12 23:45 +0100
Re: Running an editor from ANSI C tTh <tth@none.invalid> - 2024-06-12 12:37 +0200
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-12 12:10 +0100
Re: Running an editor from ANSI C David Brown <david.brown@hesbynett.no> - 2024-06-12 15:04 +0200
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-06 04:46 +0000
Re: Running an editor from ANSI C BGB <cr88192@gmail.com> - 2024-06-06 00:34 -0500
Re: Running an editor from ANSI C Mikko <mikko.levanto@iki.fi> - 2024-06-06 18:42 +0300
Re: Running an editor from ANSI C Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2024-06-06 17:08 +0100
Re: Running an editor from ANSI C scott@slp53.sl.home (Scott Lurndal) - 2024-06-06 17:56 +0000
Re: Running an editor from ANSI C Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-06-06 22:56 +0000
csiph-web