Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #79175 > unrolled thread

Text editor project in C

Started byjacobnavia <jacob@jacob.remcomp.fr>
First post2021-04-22 18:58 +0200
Last post2021-04-26 18:04 +0200
Articles 20 on this page of 96 — 27 participants

Back to article view | Back to comp.lang.c++


Contents

  Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-22 18:58 +0200
    Re: Text editor project in C Bonita Montero <Bonita.Montero@gmail.com> - 2021-04-22 19:05 +0200
    Re: Text editor project in C wij <wyniijj@gmail.com> - 2021-04-22 12:41 -0700
      Re: Text editor project in C Juha Nieminen <nospam@thanks.invalid> - 2021-04-23 07:38 +0000
        Re: Text editor project in C wij <wyniijj@gmail.com> - 2021-04-23 05:12 -0700
          Re: Text editor project in C red floyd <myob@its.invalid> - 2021-04-23 09:24 -0700
          Re: Text editor project in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-04-23 16:59 -0400
            Re: Text editor project in C wij <wyniijj@gmail.com> - 2021-04-23 21:43 -0700
              Re: Text editor project in C Ian Collins <ian-news@hotmail.com> - 2021-04-24 17:05 +1200
                Re: Text editor project in C wij <wyniijj@gmail.com> - 2021-04-24 00:50 -0700
                  Re: Text editor project in C "daniel...@gmail.com" <danielaparker@gmail.com> - 2021-04-24 08:50 -0700
                    Re: Text editor project in C wij <wyniijj@gmail.com> - 2021-04-24 10:41 -0700
                Re: Text editor project in C Öö Tiib <ootiib@hot.ee> - 2021-04-25 06:19 -0700
                  Re: Text editor project in C wij <wyniijj@gmail.com> - 2021-04-25 10:23 -0700
                    Re: Text editor project in C Öö Tiib <ootiib@hot.ee> - 2021-04-25 12:46 -0700
                      Re: Text editor project in C wij <wyniijj@gmail.com> - 2021-04-25 20:34 -0700
                        Re: Text editor project in C Öö Tiib <ootiib@hot.ee> - 2021-04-28 09:57 -0700
                          Re: Text editor project in C wij <wyniijj@gmail.com> - 2021-04-29 10:56 -0700
                  Re: Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-27 18:31 +0200
                    Re: Text editor project in C David Brown <david.brown@hesbynett.no> - 2021-04-28 09:01 +0200
                      Re: Text editor project in C Manfred <noname@add.invalid> - 2021-04-28 14:54 +0200
                        Re: Text editor project in C Juha Nieminen <nospam@thanks.invalid> - 2021-04-29 04:47 +0000
                          Re: Text editor project in C Paavo Helde <myfirstname@osa.pri.ee> - 2021-04-29 11:42 +0300
                            Re: Text editor project in C Christian Gollwitzer <auriocus@gmx.de> - 2021-04-29 23:04 +0200
    Re: Text editor project in C Juha Nieminen <nospam@thanks.invalid> - 2021-04-23 07:55 +0000
      Re: Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-23 11:25 +0200
        Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 12:45 -0700
          Re: Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-23 22:29 +0200
            Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 13:34 -0700
              Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 13:37 -0700
              Re: Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-23 22:40 +0200
                Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 13:51 -0700
                  Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 13:55 -0700
                  Re: Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-23 23:02 +0200
                    Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 14:13 -0700
                      Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 15:39 -0700
                      Re: Text editor project in C Bart <bc@freeuk.com> - 2021-04-24 01:20 +0100
                        Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 17:43 -0700
                      Re: Text editor project in C kegs@provalid.com (Kent Dickey) - 2021-04-25 00:04 -0500
                        Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-24 22:29 -0700
                        Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-24 23:05 -0700
                        Re: Text editor project in C Paavo Helde <myfirstname@osa.pri.ee> - 2021-04-25 10:57 +0300
                          Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-25 01:18 -0700
                            Re: Text editor project in C Paavo Helde <myfirstname@osa.pri.ee> - 2021-04-25 11:28 +0300
                            Re: Text editor project in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-04-25 15:02 -0400
                              Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-26 01:25 -0700
                              Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-26 01:26 -0700
                    Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 14:15 -0700
              Re: Text editor project in C scott@slp53.sl.home (Scott Lurndal) - 2021-04-23 22:25 +0000
                Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 15:31 -0700
            Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 13:38 -0700
              Re: Text editor project in C scott@slp53.sl.home (Scott Lurndal) - 2021-04-23 22:27 +0000
                Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-23 15:34 -0700
                  Re: Text editor project in C scott@slp53.sl.home (Scott Lurndal) - 2021-04-24 16:33 +0000
                    Re: Text editor project in C "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-04-24 22:59 -0700
            Re: Text editor project in C Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 05:22 +0000
              Re: Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-26 10:00 +0200
                Re: Text editor project in C Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 09:57 +0000
                  Re: Text editor project in C Robert Latest <boblatest@yahoo.com> - 2021-04-26 10:41 +0000
                  Re: Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-26 13:20 +0200
                    Re: Text editor project in C Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 13:17 +0000
                      Re: Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-26 19:53 +0200
                        Re: Text editor project in C David Brown <david.brown@hesbynett.no> - 2021-04-26 20:34 +0200
                          Re: Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-26 22:49 +0200
                            Re: Text editor project in C David Brown <david.brown@hesbynett.no> - 2021-04-27 10:59 +0200
                    Re: Text editor project in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-26 22:04 +0100
                      Re: Text editor project in C Eli the Bearded <*@eli.users.panix.com> - 2021-04-26 22:19 +0000
                        Re: Text editor project in C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-04-26 16:07 -0700
                        Re: Text editor project in C Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2021-04-26 17:08 -0600
                          Re: Text editor project in C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-04-26 16:57 -0700
                            Re: Text editor project in C Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2021-04-26 21:42 -0600
                        Re: Text editor project in C Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-27 00:46 +0000
                        Re: Text editor project in C Juha Nieminen <nospam@thanks.invalid> - 2021-04-27 04:51 +0000
                          Re: Text editor project in C Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2021-04-27 10:03 -0600
                            Re: Text editor project in C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-04-27 09:20 -0700
                            Re: Text editor project in C scott@slp53.sl.home (Scott Lurndal) - 2021-04-27 16:34 +0000
                              Re: Text editor project in C Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2021-04-27 10:55 -0600
                                Re: Text editor project in C Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-27 17:13 +0000
                                Re: Text editor project in C Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2021-04-27 17:28 +0000
                                  Re: Text editor project in C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-04-27 13:33 -0700
                                Re: Text editor project in C scott@slp53.sl.home (Scott Lurndal) - 2021-04-27 19:27 +0000
                              Re: Text editor project in C Kaz Kylheku <563-365-8930@kylheku.com> - 2021-04-27 17:11 +0000
                        Re: Text editor project in C scott@slp53.sl.home (Scott Lurndal) - 2021-04-27 14:28 +0000
                          Re: Text editor project in C Juha Nieminen <nospam@thanks.invalid> - 2021-04-27 15:11 +0000
                Re: Text editor project in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-26 21:37 +0100
                  Re: Text editor project in C jacobnavia <jacob@jacob.remcomp.fr> - 2021-04-26 22:48 +0200
                  Re: Text editor project in C scott@slp53.sl.home (Scott Lurndal) - 2021-04-26 21:53 +0000
                    Re: Text editor project in C Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-04-27 01:34 +0100
              Re: Text editor project in C Guillaume <message@bottle.org> - 2021-04-26 18:48 +0200
              Re: Text editor project in C James Kuyper <jameskuyper@alumni.caltech.edu> - 2021-04-26 13:54 -0400
      Re: Text editor project in C Jorgen Grahn <grahn+nntp@snipabacken.se> - 2021-04-23 20:00 +0000
        Re: Text editor project in C Juha Nieminen <nospam@thanks.invalid> - 2021-04-26 05:29 +0000
    Re: Text editor project in C om@iki.fi (Otto J. Makela) - 2021-04-23 19:25 +0300
    Re: Text editor project in C wij <wyniijj@gmail.com> - 2021-04-24 10:55 -0700
      Re: Text editor project in C Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-04-24 14:21 -0700
    Re: Text editor project in C Bonita Montero <Bonita.Montero@gmail.com> - 2021-04-26 18:04 +0200

Page 4 of 5 — ← Prev page 1 2 3 [4] 5  Next page →


#79292

FromJuha Nieminen <nospam@thanks.invalid>
Date2021-04-26 13:17 +0000
Message-ID<s66ehe$1mju$1@gioia.aioe.org>
In reply to#79289
In comp.lang.c++ jacobnavia <jacob@jacob.remcomp.fr> wrote:
> Le 26/04/2021 à 11:57, Juha Nieminen a écrit :
>> Can you show me a C++ program from 2000 that doesn't?
> 
> Breaking changes in C++ 2011

I think all the major C++ compilers support C++98 mode.

And it's not like C hasn't change either. This compiles as C89 but not
as C99:

#include <stdio.h>

int main()
{
    int restrict = 1, inline = 2;
    printf("%i %i\n", restrict, inline);
    return 0;
}

[toc] | [prev] | [next] | [standalone]


#79299

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2021-04-26 19:53 +0200
Message-ID<s66und$8v7$1@dont-email.me>
In reply to#79292
Le 26/04/2021 à 15:17, Juha Nieminen a écrit :
> In comp.lang.c++ jacobnavia <jacob@jacob.remcomp.fr> wrote:
>> Le 26/04/2021 à 11:57, Juha Nieminen a écrit :
>>> Can you show me a C++ program from 2000 that doesn't?
>>
>> Breaking changes in C++ 2011
> 
> I think all the major C++ compilers support C++98 mode.
> 
> And it's not like C hasn't change either. This compiles as C89 but not
> as C99:
> 
> #include <stdio.h>
> 
> int main()
> {
>      int restrict = 1, inline = 2;
>      printf("%i %i\n", restrict, inline);
>      return 0;
> }
> 

Yes, that is why I did NOT even mention the same problems that C++ has
(auto keyword, and MANY others, much more than C)

[toc] | [prev] | [next] | [standalone]


#79301

FromDavid Brown <david.brown@hesbynett.no>
Date2021-04-26 20:34 +0200
Message-ID<s67136$p59$1@dont-email.me>
In reply to#79299
On 26/04/2021 19:53, jacobnavia wrote:
> Le 26/04/2021 à 15:17, Juha Nieminen a écrit :
>> In comp.lang.c++ jacobnavia <jacob@jacob.remcomp.fr> wrote:
>>> Le 26/04/2021 à 11:57, Juha Nieminen a écrit :
>>>> Can you show me a C++ program from 2000 that doesn't?
>>>
>>> Breaking changes in C++ 2011
>>
>> I think all the major C++ compilers support C++98 mode.
>>
>> And it's not like C hasn't change either. This compiles as C89 but not
>> as C99:
>>
>> #include <stdio.h>
>>
>> int main()
>> {
>>      int restrict = 1, inline = 2;
>>      printf("%i %i\n", restrict, inline);
>>      return 0;
>> }
>>
> 
> Yes, that is why I did NOT even mention the same problems that C++ has
> (auto keyword, and MANY others, much more than C)

Yes, you did - your number 4 item was a list of new keywords whose only
backwards compatibility issue is if they happen to be used as
identifiers.  (There are more than in C99 - no arguments there.  I'd not
expect significantly more conflicts, however.)

There are a few cases where it might be reasonable to think /real/ code
written for C++03 would no longer be valid (or have the same effect)
when compiled as C++11 or newer.  But they would be rare.  Listing silly
things like defining "u8" as a macro of a string and using it for string
concatenation (without a space) is just petty.  It is not a realistic
concern, nor an example of what Juha asked for - it is just FUD, and a
sign of desperation.  You prefer C to C++ - that's fine, everyone has
their preferences.  But if you don't have real reasons, there's no need
to invent unrealistic reasons.

[toc] | [prev] | [next] | [standalone]


#79305

Fromjacobnavia <jacob@jacob.remcomp.fr>
Date2021-04-26 22:49 +0200
Message-ID<s67903$dbt$2@dont-email.me>
In reply to#79301
Le 26/04/2021 à 20:34, David Brown a écrit :
> On 26/04/2021 19:53, jacobnavia wrote:
>> Le 26/04/2021 à 15:17, Juha Nieminen a écrit :
>>> In comp.lang.c++ jacobnavia <jacob@jacob.remcomp.fr> wrote:
>>>> Le 26/04/2021 à 11:57, Juha Nieminen a écrit :
>>>>> Can you show me a C++ program from 2000 that doesn't?
>>>>
>>>> Breaking changes in C++ 2011
>>>
>>> I think all the major C++ compilers support C++98 mode.
>>>
>>> And it's not like C hasn't change either. This compiles as C89 but not
>>> as C99:
>>>
>>> #include <stdio.h>
>>>
>>> int main()
>>> {
>>>       int restrict = 1, inline = 2;
>>>       printf("%i %i\n", restrict, inline);
>>>       return 0;
>>> }
>>>
>>
>> Yes, that is why I did NOT even mention the same problems that C++ has
>> (auto keyword, and MANY others, much more than C)
> 
> Yes, you did - your number 4 item was a list of new keywords whose only
> backwards compatibility issue is if they happen to be used as
> identifiers.  (There are more than in C99 - no arguments there.  I'd not
> expect significantly more conflicts, however.)
> 
> There are a few cases where it might be reasonable to think /real/ code
> written for C++03 would no longer be valid (or have the same effect)
> when compiled as C++11 or newer.  But they would be rare.  Listing silly
> things like defining "u8" as a macro of a string and using it for string
> concatenation (without a space) is just petty.  It is not a realistic
> concern, nor an example of what Juha asked for - it is just FUD, and a
> sign of desperation.  You prefer C to C++ - that's fine, everyone has
> their preferences.  But if you don't have real reasons, there's no need
> to invent unrealistic reasons.
> 
> 

Sure sure, I am desperate. But you ignored the problem with templates... 
and many others I mentioned

[toc] | [prev] | [next] | [standalone]


#79324

FromDavid Brown <david.brown@hesbynett.no>
Date2021-04-27 10:59 +0200
Message-ID<s68jpn$3ci$1@dont-email.me>
In reply to#79305
On 26/04/2021 22:49, jacobnavia wrote:
> Le 26/04/2021 à 20:34, David Brown a écrit :
>> On 26/04/2021 19:53, jacobnavia wrote:
>>> Le 26/04/2021 à 15:17, Juha Nieminen a écrit :
>>>> In comp.lang.c++ jacobnavia <jacob@jacob.remcomp.fr> wrote:
>>>>> Le 26/04/2021 à 11:57, Juha Nieminen a écrit :
>>>>>> Can you show me a C++ program from 2000 that doesn't?
>>>>>
>>>>> Breaking changes in C++ 2011
>>>>
>>>> I think all the major C++ compilers support C++98 mode.
>>>>
>>>> And it's not like C hasn't change either. This compiles as C89 but not
>>>> as C99:
>>>>
>>>> #include <stdio.h>
>>>>
>>>> int main()
>>>> {
>>>>       int restrict = 1, inline = 2;
>>>>       printf("%i %i\n", restrict, inline);
>>>>       return 0;
>>>> }
>>>>
>>>
>>> Yes, that is why I did NOT even mention the same problems that C++ has
>>> (auto keyword, and MANY others, much more than C)
>>
>> Yes, you did - your number 4 item was a list of new keywords whose only
>> backwards compatibility issue is if they happen to be used as
>> identifiers.  (There are more than in C99 - no arguments there.  I'd not
>> expect significantly more conflicts, however.)
>>
>> There are a few cases where it might be reasonable to think /real/ code
>> written for C++03 would no longer be valid (or have the same effect)
>> when compiled as C++11 or newer.  But they would be rare.  Listing silly
>> things like defining "u8" as a macro of a string and using it for string
>> concatenation (without a space) is just petty.  It is not a realistic
>> concern, nor an example of what Juha asked for - it is just FUD, and a
>> sign of desperation.  You prefer C to C++ - that's fine, everyone has
>> their preferences.  But if you don't have real reasons, there's no need
>> to invent unrealistic reasons.
>>
>>
> 
> Sure sure, I am desperate. But you ignored the problem with templates...
> and many others I mentioned

I didn't ignore them, I just didn't mention them.  There /are/ backwards
incompatible changes between C++03 and C++11 (and later versions).  Some
of these will be in language or library features that might well occur
in real code.  It would be perfectly reasonable to point out these
differences - especially if you can give examples or references to real
cases.

What is /unreasonable/ and shows desperation (perhaps people moving to
C++ is bad for your business) is listing every little point you can
think of, regardless of realism.  It makes a mockery of your /real/ points.

[toc] | [prev] | [next] | [standalone]


#79306

FromBen Bacarisse <ben.usenet@bsb.me.uk>
Date2021-04-26 22:04 +0100
Message-ID<877dkohi65.fsf@bsb.me.uk>
In reply to#79289
jacobnavia <jacob@jacob.remcomp.fr> writes:

> 2) #define u8 "abc"
> const char *s = u8"def"; // Previously "abcdef", now "def"

C has the same breaking change, but, just as with C++, you can usually
ask the compiler to use an older standard.

> Only in C you can still use the code of 50 years ago.

There was no C code 50 years ago.  This is a bit of a quibble since
there was C code we'd just about recognise in about 1973 or 4, but some
of it would fool even gcc today.  The biggest change was the great =<op>
to <op>= switch.  This silently changed the meaning of a lot of code.

-- 
Ben.

[toc] | [prev] | [next] | [standalone]


#79309

FromEli the Bearded <*@eli.users.panix.com>
Date2021-04-26 22:19 +0000
Message-ID<eli$2104261749@qaz.wtf>
In reply to#79306
In comp.lang.c, Ben Bacarisse  <ben.usenet@bsb.me.uk> wrote:
> There was no C code 50 years ago.  This is a bit of a quibble since
> there was C code we'd just about recognise in about 1973 or 4, but some
> of it would fool even gcc today.  The biggest change was the great =<op>
> to <op>= switch.  This silently changed the meaning of a lot of code.

Maybe five years ago I tried to compile some C code I found in buried
in a tar file on a dusty ftp server[*]. The READ_ME implied it was last
touched in June of 1980, the filename agreed with the year.

Things I found tricky about the code:

1. It predated printf being called that. I think it was just using
   print(). And that used "-lS" in the Makefile.

2. Prototypes? Who needs em? ("#include <stdio.h>"? What, why?)

3. No need to declare ints, eg:
       main(argc, argv)
       char **argv;
       {

4. Structs are implicitly unions:
       struct  plot {
           char    p_x;
           char    p_y;
       } p_plot[LIM_PLOTS];

       /* ... */

       struct        {
             int     p_xy;           /* used to set/transfer entire plot */
       };

5. Implicit in above: seems like there is the expectation that
   sizeof(int) == 2.


Items 1 to 3 made things difficult. Items 4 and 5 meant actual code
audits were needed.

[*] I last saw it here, but that 404's today:
    http://mirror.cc.vt.edu/pub2/Ancient_Unix/Applications/Shoppa_Tapes/usenix_80_delaware.tar.gz

Elijah
------
the .c files were easier to make sense of than the .o files included

[toc] | [prev] | [next] | [standalone]


#79310

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2021-04-26 16:07 -0700
Message-ID<87eeewbq65.fsf@nosuchdomain.example.com>
In reply to#79309
Eli the Bearded <*@eli.users.panix.com> writes:
> In comp.lang.c, Ben Bacarisse  <ben.usenet@bsb.me.uk> wrote:
>> There was no C code 50 years ago.  This is a bit of a quibble since
>> there was C code we'd just about recognise in about 1973 or 4, but some
>> of it would fool even gcc today.  The biggest change was the great =<op>
>> to <op>= switch.  This silently changed the meaning of a lot of code.
>
> Maybe five years ago I tried to compile some C code I found in buried
> in a tar file on a dusty ftp server[*]. The READ_ME implied it was last
> touched in June of 1980, the filename agreed with the year.
>
> Things I found tricky about the code:
>
> 1. It predated printf being called that. I think it was just using
>    print(). And that used "-lS" in the Makefile.

I believe printf is older than C.  A form of it existed by that name in
B, and it's used (with an implementation presented) in the 1974 and 1975
editions of the C manual.  But a particular program might have chosen to
use something else.

> 2. Prototypes? Who needs em? ("#include <stdio.h>"? What, why?)

Prototypes still aren't mandatory, though calling printf without a
visible declaration has been a constraint violation since 1999 (and
undefined behavior in C89/C90, but very likely to work).

> 3. No need to declare ints, eg:
>        main(argc, argv)
>        char **argv;
>        {

Valid in C90.  Add "int" to main and argc and it's still valid (but
obsolescent).

> 4. Structs are implicitly unions:
>        struct  plot {
>            char    p_x;
>            char    p_y;
>        } p_plot[LIM_PLOTS];
>
>        /* ... */
>
>        struct        {
>              int     p_xy;           /* used to set/transfer entire plot */
>        };

A struct member name implied a type and offset, and was not tied to
the struct type.  That's why a lot of member names have unique prefixes,
like tm_sec and friends.  I think C89/C90 changed that.

> 5. Implicit in above: seems like there is the expectation that
>    sizeof(int) == 2.

There were implementations with sizeof(int)!=2 as early as the late
1980s, but there's never been any shortage of non-portable code.

> Items 1 to 3 made things difficult. Items 4 and 5 meant actual code
> audits were needed.
>
> [*] I last saw it here, but that 404's today:
>     http://mirror.cc.vt.edu/pub2/Ancient_Unix/Applications/Shoppa_Tapes/usenix_80_delaware.tar.gz
>
> Elijah
> ------
> the .c files were easier to make sense of than the .o files included

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


#79311

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2021-04-26 17:08 -0600
Message-ID<1bpmygr6d2.fsf@pfeifferfamily.net>
In reply to#79309
Eli the Bearded <*@eli.users.panix.com> writes:

> In comp.lang.c, Ben Bacarisse  <ben.usenet@bsb.me.uk> wrote:
>> There was no C code 50 years ago.  This is a bit of a quibble since
>> there was C code we'd just about recognise in about 1973 or 4, but some
>> of it would fool even gcc today.  The biggest change was the great =<op>
>> to <op>= switch.  This silently changed the meaning of a lot of code.
>
> Maybe five years ago I tried to compile some C code I found in buried
> in a tar file on a dusty ftp server[*]. The READ_ME implied it was last
> touched in June of 1980, the filename agreed with the year.
>
> Things I found tricky about the code:
>
> 1. It predated printf being called that. I think it was just using
>    print(). And that used "-lS" in the Makefile.

It was called printf() at least as long ago as Kernighan's "Programming
in C -  A Tutorial", which dates from 1974.  So the print() you came
across was some other function.

> 2. Prototypes? Who needs em? ("#include <stdio.h>"? What, why?)
>
> 3. No need to declare ints, eg:
>        main(argc, argv)
>        char **argv;
>        {
>
> 4. Structs are implicitly unions:
>        struct  plot {
>            char    p_x;
>            char    p_y;
>        } p_plot[LIM_PLOTS];
>
>        /* ... */
>
>        struct        {
>              int     p_xy;           /* used to set/transfer entire plot */
>        };

*Lord* that one bit me hard early on.  Having all struct members
use a single namespace is a decision I still don't understand (I don't
care how limited the machines running the compiler were).

> 5. Implicit in above: seems like there is the expectation that
>    sizeof(int) == 2.
>
>
> Items 1 to 3 made things difficult. Items 4 and 5 meant actual code
> audits were needed.
>
> [*] I last saw it here, but that 404's today:
>     http://mirror.cc.vt.edu/pub2/Ancient_Unix/Applications/Shoppa_Tapes/usenix_80_delaware.tar.gz
>
> Elijah
> ------
> the .c files were easier to make sense of than the .o files included

[toc] | [prev] | [next] | [standalone]


#79312

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2021-04-26 16:57 -0700
Message-ID<87a6pkbnuj.fsf@nosuchdomain.example.com>
In reply to#79311
Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
> Eli the Bearded <*@eli.users.panix.com> writes:
[...]
>> 4. Structs are implicitly unions:
>>        struct  plot {
>>            char    p_x;
>>            char    p_y;
>>        } p_plot[LIM_PLOTS];
>>
>>        /* ... */
>>
>>        struct        {
>>              int     p_xy;           /* used to set/transfer entire plot */
>>        };
>
> *Lord* that one bit me hard early on.  Having all struct members
> use a single namespace is a decision I still don't understand (I don't
> care how limited the machines running the compiler were).

As of the 1975 C manual, a "prefix.identifier" or "prefix->identifier"
expression *assumed* that the LHS was of the correct type.  For "->",
it wasn't even required to be a pointer; it could be a pointer,
character, or integer.

K&R1 (1978) imposed the requirement for the LHS to be of the correct
struct or union type for "." or a pointer to the correct struct or union
type for "->".

If you ran into that problem, it must have been some very early code
and/or a very old compiler.

I've used a compiler (VAXC) that knew about the modern "+=" compound
assignment operators, but also accepted the older "=+" forms -- and
preferred them in ambiguous cases.  That was in the late 1990s.  That's
also a change that was made between 1975 and K&R1 in 1978.  Fortunately,
though VAXC was available, we mostly used the more modern DECC.

[...]

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


#79318

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2021-04-26 21:42 -0600
Message-ID<1blf94qtoi.fsf@pfeifferfamily.net>
In reply to#79312
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
>>
>> *Lord* that one bit me hard early on.  Having all struct members
>> use a single namespace is a decision I still don't understand (I don't
>> care how limited the machines running the compiler were).
>
> As of the 1975 C manual, a "prefix.identifier" or "prefix->identifier"
> expression *assumed* that the LHS was of the correct type.  For "->",
> it wasn't even required to be a pointer; it could be a pointer,
> character, or integer.
>
> K&R1 (1978) imposed the requirement for the LHS to be of the correct
> struct or union type for "." or a pointer to the correct struct or union
> type for "->".
>
> If you ran into that problem, it must have been some very early code
> and/or a very old compiler.

It wasn't an old compiler... at the time...  it was roughly 1977 or so.

[toc] | [prev] | [next] | [standalone]


#79315

FromKaz Kylheku <563-365-8930@kylheku.com>
Date2021-04-27 00:46 +0000
Message-ID<20210426173148.187@kylheku.com>
In reply to#79309
On 2021-04-26, Eli the Bearded <*@eli.users.panix.com> wrote:
> In comp.lang.c, Ben Bacarisse  <ben.usenet@bsb.me.uk> wrote:
>> There was no C code 50 years ago.  This is a bit of a quibble since
>> there was C code we'd just about recognise in about 1973 or 4, but some
>> of it would fool even gcc today.  The biggest change was the great =<op>
>> to <op>= switch.  This silently changed the meaning of a lot of code.
>
> Maybe five years ago I tried to compile some C code I found in buried
> in a tar file on a dusty ftp server[*]. The READ_ME implied it was last
> touched in June of 1980, the filename agreed with the year.
>
> Things I found tricky about the code:
>
> 1. It predated printf being called that. I think it was just using
>    print(). And that used "-lS" in the Makefile.
>
> 2. Prototypes? Who needs em? ("#include <stdio.h>"? What, why?)

Version 7 Unix in 1979 had <stdio.h>, and fprintf and printf functions,
wrappers around an assembly language routine taking the stream as a
parameter.  In version 5 (1974), printf was still a dedicated assembly
routine. It had the "f" in the name.

> 3. No need to declare ints, eg:
>        main(argc, argv)
>        char **argv;
>        {
>
> 4. Structs are implicitly unions:
>        struct  plot {
>            char    p_x;
>            char    p_y;
>        } p_plot[LIM_PLOTS];
>
>        /* ... */
>
>        struct        {
>              int     p_xy;           /* used to set/transfer entire plot */
>        };

That was a feature of early C. Basically, no type checking. If you
wrote

   ptr->member

then it would look up member in a global dictionary of *all* structure
members that have been declared in the translation unit, and not in the
*ptr type! And then it would just generate the machine code to access
the pointer relative to that offset.

This is part of the reason why Unix structure members have prefixes,
just like the convention you see in the code you found above.

E.g. "struct stat" has "st_mtime", "st_size" and so on.

That situation persists until today.

Another funny fact is that some early compilers used a static buffer for
returning structs instead of the stack. Oops, not safe w.r.t. signals or
threading.

> 5. Implicit in above: seems like there is the expectation that
>    sizeof(int) == 2.

Newly written code today has assumptions like this. TOns of code written
for 16-bit systems (PC's with MS-DOS, for instance) was riddled with
sizeof(int) == 2 == 16 bits assumptions.

-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

[toc] | [prev] | [next] | [standalone]


#79321

FromJuha Nieminen <nospam@thanks.invalid>
Date2021-04-27 04:51 +0000
Message-ID<s68596$17de$1@gioia.aioe.org>
In reply to#79309
In comp.lang.c++ Eli the Bearded <*@eli.users.panix.com> wrote:
> 5. Implicit in above: seems like there is the expectation that
>    sizeof(int) == 2.

That's actually a good point, which I didn't myself think of earlier.

Several arguments have been made in this thread that C is very "portable",
and that C code written in the 1970's still compiles and works just fine
(well, at least if you tell gcc/clang to use the C89 standard, hopefully).

However, the undetermined size of basic types (especially before
standardization) makes it more likely for C programs, especially ones
written back then, to be non-portable. Sure, even back when K&R first
"soft-standardized" the C language you shouldn't have assumed a certain
size for any basic type.

(I don't know if sizeof(char) was guaranteed to be 1 even since K&R,
but even then, and to this day, you can't really trust that it's actually
one 8-bit byte, only that the sizes of all other types are multiples of it.)

There were no fancy uint32_t and other such type aliases back then
(and not even in C89), so there wasn't really a sure way to have a basic
type of a particular size. (You can check if a basic type is of a given
size with #if, and try several of them to see if one of them is of
the desired size, and produce an #error if none of them are, but that's
as far as you could go. In fact, even today that's technically as far
as you can go, even with the possibly existing standard typedefs.)

For most code it's enough for basic types to have a minimum size, but this
isn't always the case, and it's easy to write code that assumes a particular
size for such a type and breaks if it actually isn't of that size.

I suppose the conclusion is that maybe C code written in the 70's does
compile and work today... but only if it was properly written. If it
wasn't properly written, it's perfectly possible it won't work today,
in a different architecture than it was originally written for
(for example because it assumes the wrong size for 'int'.)

[toc] | [prev] | [next] | [standalone]


#79331

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2021-04-27 10:03 -0600
Message-ID<1bv9871zql.fsf@pfeifferfamily.net>
In reply to#79321
Juha Nieminen <nospam@thanks.invalid> writes:

> However, the undetermined size of basic types (especially before
> standardization) makes it more likely for C programs, especially ones
> written back then, to be non-portable. Sure, even back when K&R first
> "soft-standardized" the C language you shouldn't have assumed a certain
> size for any basic type.

Everybody "knew" longs were 32 bits, shorts and ints were both 16 bits,
chars were 8 bits and we coded under that assumption.  Lots and lots of
code broke when we moved from 16 bit to 32 bit machines and the size of
an int changed as a result.

<snip>

> I suppose the conclusion is that maybe C code written in the 70's does
> compile and work today... but only if it was properly written. If it
> wasn't properly written, it's perfectly possible it won't work today,
> in a different architecture than it was originally written for
> (for example because it assumes the wrong size for 'int'.)

Correct (as those of us who are old enough learned in the 80s!).

[toc] | [prev] | [next] | [standalone]


#79332

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2021-04-27 09:20 -0700
Message-ID<871ravbsy3.fsf@nosuchdomain.example.com>
In reply to#79331
Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
> Juha Nieminen <nospam@thanks.invalid> writes:
>> However, the undetermined size of basic types (especially before
>> standardization) makes it more likely for C programs, especially ones
>> written back then, to be non-portable. Sure, even back when K&R first
>> "soft-standardized" the C language you shouldn't have assumed a certain
>> size for any basic type.
>
> Everybody "knew" longs were 32 bits, shorts and ints were both 16 bits,
> chars were 8 bits and we coded under that assumption.  Lots and lots of
> code broke when we moved from 16 bit to 32 bit machines and the size of
> an int changed as a result.

Everybody who programmed on PDP-11s knew that.  There were other
configurations at least as early as K&R1, 1978.  But most programmers at
the time probably wouldn't have worked on more than one system.

> <snip>
>
>> I suppose the conclusion is that maybe C code written in the 70's does
>> compile and work today... but only if it was properly written. If it
>> wasn't properly written, it's perfectly possible it won't work today,
>> in a different architecture than it was originally written for
>> (for example because it assumes the wrong size for 'int'.)
>
> Correct (as those of us who are old enough learned in the 80s!).
>

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


#79334

Fromscott@slp53.sl.home (Scott Lurndal)
Date2021-04-27 16:34 +0000
Message-ID<h2XhI.151573$2A5.5709@fx45.iad>
In reply to#79331
Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
>Juha Nieminen <nospam@thanks.invalid> writes:
>
>> However, the undetermined size of basic types (especially before
>> standardization) makes it more likely for C programs, especially ones
>> written back then, to be non-portable. Sure, even back when K&R first
>> "soft-standardized" the C language you shouldn't have assumed a certain
>> size for any basic type.
>
>Everybody "knew" longs were 32 bits, shorts and ints were both 16 bits,
>chars were 8 bits and we coded under that assumption.  Lots and lots of
>code broke when we moved from 16 bit to 32 bit machines and the size of
>an int changed as a result.
>

And, unfortunately, the types often were not abstracted behind
a typedef.  The process identifer, group identifier and user
identifers were all 16-bit as well.  This made for a painful
conversion to 32-bit PID/GID/UID in SVR4 (accompanied by abstract
types pid_t, gid_t, uid_t which, when used correctly, mean that
applications only needed a simple recompile to handle a change in width).

[toc] | [prev] | [next] | [standalone]


#79335

FromJoe Pfeiffer <pfeiffer@cs.nmsu.edu>
Date2021-04-27 10:55 -0600
Message-ID<1bo8dz1xbq.fsf@pfeifferfamily.net>
In reply to#79334
scott@slp53.sl.home (Scott Lurndal) writes:

> Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
>>Juha Nieminen <nospam@thanks.invalid> writes:
>>
>>> However, the undetermined size of basic types (especially before
>>> standardization) makes it more likely for C programs, especially ones
>>> written back then, to be non-portable. Sure, even back when K&R first
>>> "soft-standardized" the C language you shouldn't have assumed a certain
>>> size for any basic type.
>>
>>Everybody "knew" longs were 32 bits, shorts and ints were both 16 bits,
>>chars were 8 bits and we coded under that assumption.  Lots and lots of
>>code broke when we moved from 16 bit to 32 bit machines and the size of
>>an int changed as a result.
>>
>
> And, unfortunately, the types often were not abstracted behind
> a typedef.  The process identifer, group identifier and user
> identifers were all 16-bit as well.  This made for a painful
> conversion to 32-bit PID/GID/UID in SVR4 (accompanied by abstract
> types pid_t, gid_t, uid_t which, when used correctly, mean that
> applications only needed a simple recompile to handle a change in width).

There were no typedefs back then (at least I don't remember them that
far back, and they don't appear in either Ritchie's reference manual nor
Kernighan's tutorial).

[toc] | [prev] | [next] | [standalone]


#79337

FromKaz Kylheku <563-365-8930@kylheku.com>
Date2021-04-27 17:13 +0000
Message-ID<20210427101137.594@kylheku.com>
In reply to#79335
On 2021-04-27, Joe Pfeiffer <pfeiffer@cs.nmsu.edu> wrote:
> scott@slp53.sl.home (Scott Lurndal) writes:
>> And, unfortunately, the types often were not abstracted behind
>> a typedef.  The process identifer, group identifier and user
>> identifers were all 16-bit as well.  This made for a painful
>> conversion to 32-bit PID/GID/UID in SVR4 (accompanied by abstract
>> types pid_t, gid_t, uid_t which, when used correctly, mean that
>> applications only needed a simple recompile to handle a change in width).
>
> There were no typedefs back then (at least I don't remember them that
> far back, and they don't appear in either Ritchie's reference manual nor
> Kernighan's tutorial).

The preprocessor was used for type definitions; that's why FILE is capitalized.

  #define FILE struct _iobuf

or something like that. The Indian Hill naming (typedefs are all caps)
that spilled into MS Windows is probably inspired by that.


-- 
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

[toc] | [prev] | [next] | [standalone]


#79338

FromLew Pitcher <lew.pitcher@digitalfreehold.ca>
Date2021-04-27 17:28 +0000
Message-ID<s69hkk$dmr$1@dont-email.me>
In reply to#79335
On Tue, 27 Apr 2021 10:55:37 -0600, Joe Pfeiffer wrote:

> scott@slp53.sl.home (Scott Lurndal) writes:
> 
>> Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
>>>Juha Nieminen <nospam@thanks.invalid> writes:
>>>
>>>> However, the undetermined size of basic types (especially before
>>>> standardization) makes it more likely for C programs, especially ones
>>>> written back then, to be non-portable. Sure, even back when K&R first
>>>> "soft-standardized" the C language you shouldn't have assumed a certain
>>>> size for any basic type.
>>>
>>>Everybody "knew" longs were 32 bits, shorts and ints were both 16 bits,
>>>chars were 8 bits and we coded under that assumption.  Lots and lots of
>>>code broke when we moved from 16 bit to 32 bit machines and the size of
>>>an int changed as a result.
>>>
>>
>> And, unfortunately, the types often were not abstracted behind
>> a typedef.  The process identifer, group identifier and user
>> identifers were all 16-bit as well.  This made for a painful
>> conversion to 32-bit PID/GID/UID in SVR4 (accompanied by abstract
>> types pid_t, gid_t, uid_t which, when used correctly, mean that
>> applications only needed a simple recompile to handle a change in width).
> 
> There were no typedefs back then (at least I don't remember them that
> far back, and they don't appear in either Ritchie's reference manual nor
> Kernighan's tutorial).

FWIW, my copy of K&R (Copyright 1978) has a whole section (Chapter 6.9) on typedefs
The "C Programming Language - Reference Manual" (by Dennis M. Richie) published as
Appendix A of that edition of K&R also includes a section (8.8 Typedef) on typedef,
along with the BNF for it in section 18.2 ("Declarations").


-- 
Lew Pitcher
"In Skills, We Trust"

[toc] | [prev] | [next] | [standalone]


#79340

FromKeith Thompson <Keith.S.Thompson+u@gmail.com>
Date2021-04-27 13:33 -0700
Message-ID<87wnsna2nv.fsf@nosuchdomain.example.com>
In reply to#79338
Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
> On Tue, 27 Apr 2021 10:55:37 -0600, Joe Pfeiffer wrote:
>> scott@slp53.sl.home (Scott Lurndal) writes:
>>> Joe Pfeiffer <pfeiffer@cs.nmsu.edu> writes:
>>>>Juha Nieminen <nospam@thanks.invalid> writes:
>>>>> However, the undetermined size of basic types (especially before
>>>>> standardization) makes it more likely for C programs, especially ones
>>>>> written back then, to be non-portable. Sure, even back when K&R first
>>>>> "soft-standardized" the C language you shouldn't have assumed a certain
>>>>> size for any basic type.
>>>>
>>>>Everybody "knew" longs were 32 bits, shorts and ints were both 16 bits,
>>>>chars were 8 bits and we coded under that assumption.  Lots and lots of
>>>>code broke when we moved from 16 bit to 32 bit machines and the size of
>>>>an int changed as a result.
>>>>
>>>
>>> And, unfortunately, the types often were not abstracted behind
>>> a typedef.  The process identifer, group identifier and user
>>> identifers were all 16-bit as well.  This made for a painful
>>> conversion to 32-bit PID/GID/UID in SVR4 (accompanied by abstract
>>> types pid_t, gid_t, uid_t which, when used correctly, mean that
>>> applications only needed a simple recompile to handle a change in width).
>> 
>> There were no typedefs back then (at least I don't remember them that
>> far back, and they don't appear in either Ritchie's reference manual nor
>> Kernighan's tutorial).
>
> FWIW, my copy of K&R (Copyright 1978) has a whole section (Chapter 6.9) on typedefs
> The "C Programming Language - Reference Manual" (by Dennis M. Richie) published as
> Appendix A of that edition of K&R also includes a section (8.8 Typedef) on typedef,
> along with the BNF for it in section 18.2 ("Declarations").

https://www.bell-labs.com/usr/dmr/www/cman.pdf (1975) doesn't mention typedef.
K&R1 (1978) does.  That's as far as I've been able to narrow it down.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */

[toc] | [prev] | [next] | [standalone]


Page 4 of 5 — ← Prev page 1 2 3 [4] 5  Next page →

Back to top | Article view | comp.lang.c++


csiph-web