News for hackers. Stuff that matters.
Re:Old C code – how to upgrade it? by compressedgas on Friday April 08, 2022 @05:23PM (#30962670)
I had actually got this to build and run. These are the changes I made to get it to compile under gcc 4.6.3 with -std=gnu89:

  --- stoical-0.1.8-old/src/debug.c 2002-05-05 06:41:19.000000000 -0400
  +++ stoical-0.1.8-new/src/debug.c 2020-10-01 14:32:34.000000000 -0400
  @@ -139,7 +139,8 @@
     else if ( strcmp( (*p)->name, "l()" ) == 0 )
     {
      p++;
  -   st_pcell( ((cell*)p)++ );
  +   st_pcell( ((cell*)p) );
  +   p = (cell*)p + 1;
      p--;
     }
     else if ( strcmp( (*p)->name, "r()" ) == 0 ||
  diff -ru stoical-0.1.8-old/src/help.h stoical-0.1.8-new/src/help.h
  --- stoical-0.1.8-old/src/help.h 2002-04-25 16:06:20.000000000 -0400
  +++ stoical-0.1.8-new/src/help.h 2020-10-01 09:26:45.000000000 -0400
  @@ -1,18 +1,18 @@
  -const char help[] = "S t o i c a l  %s 
  -Copyright (c) 2002 Jonathan Moore Liles.
  -Released under the GNU General Public License (see COPYING)
  -
  -usage:
  -stoical [ option ] ... [ file ] [ arg ] ... 
  -
  -The available options include:
  -
  --h   - Print this help and exit.
  --v   - Print version information and exit.
  --e code   - Exectue the instructions 'code'.
  --l path   - Change STOICAL root library path.
  --f file   - Run 'file' (useful when file begins with a '-').
  -
  -";
  +const char help[] = "S t o i c a l  %s "
  +"Copyright (c) 2002 Jonathan Moore Liles."
  +"Released under the GNU General Public License (see COPYING)"
  +""
  +"usage:"
  +"stoical [ option ] ... [ file ] [ arg ] ... "
  +""
  +"The available options include:"
  +""
  +"-h   - Print this help and exit."
  +"-v   - Print version information and exit."
  +"-e code   - Exectue the instructions 'code'."
  +"-l path   - Change STOICAL root library path."
  +"-f file   - Run 'file' (useful when file begins with a '-')."
  +""
  +"";
  diff -ru stoical-0.1.8-old/src/words.c stoical-0.1.8-new/src/words.c
  --- stoical-0.1.8-old/src/words.c 2002-05-07 06:54:02.000000000 -0400
  +++ stoical-0.1.8-new/src/words.c 2020-10-01 14:33:49.000000000 -0400
  @@ -2009,8 +2009,8 @@
   begin(hash_put)
    /* Place character represented by the value at TOS into
     * the buffer. Decrement the pointer, and increment the count. */
  - *(--(char*)hash_ptr.parm.v.p) = fpop(sst);
  - 
  + *((char*)hash_ptr.parm.v.p) = fpop(sst);
  + hash_ptr.parm.v.p = (char*)hash_ptr.parm.v.p - 1;
    hash_cnt.parm.v.f++;
   end()
   begin(hash_a)
  @@ -2789,7 +2789,8 @@
    ip++;
    a = (cell*)ip;
    
  - ((cell*)ip)++;
  + ip = (cell*)ip + 1;
    ip--;
   
    push(sst,*a);
Re:Old C code – how to upgrade it? by zoomablemind on Saturday April 09, 2022 @04:04AM (#30966093)
> ...

     /* Place character represented by the value at TOS into
     * the buffer. Decrement the pointer, and increment the count. */
  - *(--(char*)hash_ptr.parm.v.p) = fpop(sst);
  - 
  + *((char*)hash_ptr.parm.v.p) = fpop(sst);
  + hash_ptr.parm.v.p = (char*)hash_ptr.parm.v.p - 1;

Are you sure that making assignment before the predecrement is how this fragment should be functioning?
Re:Old C code – how to upgrade it? by compressedgas on Saturday April 09, 2022 @04:31AM (#30966219)
The two lines should be swapped.
Re:Old C code – how to upgrade it? by ketchupdog on Friday April 08, 2022 @07:09PM (#30963603)
Did the examples work for you? I got the threads example to run on an M1 building with clang, but the dir example fails.
Re:Old C code – how to upgrade it? by compressedgas on Friday April 08, 2022 @07:30PM (#30963744)
I didn't test the examples. I sort of stopped once I got `1 2 +` to work.
Re:Old C code – how to upgrade it? by compressedgas on Friday April 08, 2022 @06:42PM (#30963392)
I think the third chunk should have its two new lines swapped.