Add mes and mescc-tools-extra

mescc-tools-extra contains two important tools:
- cp
- chmod

mes first builds itself from a mes 0.21 seed as used by guix, and then
builds a mes 0.22 and then mes 0.22 using that created mes 0.22.

It does /not/ use bootstrap.sh as we don't have a proper shell at this
point, it has been manually adapted for kaem.
This commit is contained in:
fosslinux 2020-12-25 18:40:14 +11:00
parent 2706e07556
commit 649d7b68dc
1029 changed files with 120985 additions and 18 deletions

View file

@ -0,0 +1,25 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
return 0;
}

View file

@ -0,0 +1,25 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
return 1;
}

View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1,31 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
test0 ()
{
return 0;
}
int
main ()
{
return test0 ();
}

View file

@ -0,0 +1,31 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
testi (int t)
{
return t;
}
int
main ()
{
return testi (0);
}

View file

@ -0,0 +1,31 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
testi (int t)
{
return t;
}
int
main ()
{
return testi (1);
}

View file

@ -0,0 +1 @@
1

View file

@ -0,0 +1,32 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
test (int a, int b)
{
return a + b;
}
int
main ()
{
int i = -2;
return test (i, 2);
}

View file

@ -0,0 +1,31 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
testi (int t)
{
return !t;
}
int
main ()
{
return testi (1);
}

View file

@ -0,0 +1,31 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
test (char const *s)
{
return 0;
}
int
main ()
{
return test ("hello\n");
}

View file

@ -0,0 +1,34 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
test (int a)
{
return 1 - a;
}
int (*f) (int);
int
main ()
{
f = &test;
return (*f) (1);
}

View file

@ -0,0 +1,31 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
test ()
{
return 1;
}
int
main ()
{
return !test ();
}

View file

@ -0,0 +1,33 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
void
test ()
{
return;
}
int
main ()
{
test ();
return 0;
}

View file

@ -0,0 +1,27 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include "exit-42.i"
int
main ()
{
return 1;
}

View file

@ -0,0 +1 @@
42

View file

@ -0,0 +1,32 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int foo;
int
main ()
{
if (foo)
return 1;
foo = 42;
if (foo != 42)
return 2;
return 0;
}

View file

@ -0,0 +1,29 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
int a;
int b;
a = 1;
b = -a;
return a + b;
}

View file

@ -0,0 +1,32 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
int a;
int b;
int c;
a = 2;
b = -2;
c = a + b;
asm ("nop");
return c;
}

View file

@ -0,0 +1,27 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
if (0)
return 1;
return 0;
}

View file

@ -0,0 +1,27 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
if (1)
return 0;
return 1;
}

View file

@ -0,0 +1,27 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
if (0 == 0)
return 0;
return 1;
}

View file

@ -0,0 +1,27 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
if (0 != 1)
return 0;
return 1;
}

View file

@ -0,0 +1,33 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
if (0 == 0)
goto ok;
return 1;
ok:
if (0 != 1)
goto ok1;
return 1;
ok1:
return 0;
}

View file

@ -0,0 +1,28 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
int f = 0;
if (!f)
return 0;
return 1;
}

View file

@ -0,0 +1,28 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
int t = 1;
if (t)
return 0;
return 1;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
char c = 'a';
if (c >= 'A' && c <= 'Z' || c >= '0' && c <= '9')
return 1;
if (c >= 'A' && c <= 'Z' || c >= 'a' && c <= 'a')
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
char c = 'a';
if (c >= 'A' && c <= 'Z')
return 1;
if (c >= 'a' && c <= 'z')
return 0;
return 2;
}

View file

@ -0,0 +1,38 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
int
test (int i)
{
return i;
}
int
main ()
{
int a;
a = 0 == 0;
if (a != 1)
return 1;
return 0;
}

View file

@ -0,0 +1,38 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
int
test (int i)
{
return i;
}
int
main ()
{
int a;
a = test (0 == 0);
if (a != 1)
return 1;
return 0;
}

View file

@ -0,0 +1,31 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
if ('0' != 48)
return 1;
if ('\a' != 7)
return 2;
if ('\b' != 8)
return 3;
return 0;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
int r = 0;
if (r > 0)
return 1;
if (r >= -1)
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
int r = 0;
if (r > 0)
return 1;
if (r > -1)
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
int r = 0;
if (r <= -1)
return 1;
if (r <= 0)
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
int r = 0;
if (r < -1)
return 1;
if (r < 1)
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
char c = 'a';
if (c == ' ' || c == '\n')
return 1;
if (c == 'A' || c == 'a')
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
unsigned char r = -2;
if (r <= -3)
return 1;
if (r <= (unsigned char) -1)
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
unsigned r = -2;
if (r <= -1)
return 0;
if (r <= -3)
return 1;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
unsigned r = -2;
if (r > -1)
return 1;
if (r > 0)
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
unsigned r = -2;
if (r <= -3)
return 1;
if (r <= -1)
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
unsigned long r = -2;
if (r <= -3)
return 1;
if (r <= -1)
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
unsigned r = -2;
if (r < 0)
return 1;
if (r < -1)
return 0;
return 2;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
unsigned short r = -2;
if (r <= -3)
return 1;
if (r <= (unsigned short) -1)
return 0;
return 2;
}

View file

@ -0,0 +1,34 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
int
main ()
{
int c = 0;
{
int c = 3;
}
if (c)
return 1;
return 0;
}

View file

@ -0,0 +1,28 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
int v = 3;
while (v)
v--;
return v;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
char *s = "mes";
if (!s[0])
return 1;
if (s[1] != 'e')
return 2;
return 0;
}

View file

@ -0,0 +1,36 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
char *s = "mes";
if (!s[0])
return 1;
int f;
int v = 3;
if (!s[f])
return 2;
if (s[3])
return 3;
if (s[v])
return 4;
return 0;
}

View file

@ -0,0 +1,31 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
char *s = "mes";
int i = 0;
while (s[i])
i++;
if (i != 3)
return 1;
return 0;
}

View file

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int *foo;
//int bar = -1;
int
main ()
{
if (foo)
return 1;
return 0;
}

View file

@ -0,0 +1,33 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int foo = 1;
int *bar = &foo;
int baz = -1;
int
main ()
{
if (foo != 1)
return 1;
if (*bar != 1)
return 2;
return 0;
}

View file

@ -0,0 +1,33 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
char *g_hello = "hello";
int
main ()
{
// char *p = g_hello;
// char **pp = &p;
char **pp = &g_hello;
if (**pp != 'h')
return 1;
return 0;
}

View file

@ -0,0 +1,31 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
char *g_hello = "hello";
int
main ()
{
char *p = g_hello;
if (*p != 'h')
return 1;
return 0;
}

View file

@ -0,0 +1,32 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
int
main ()
{
char *begin = "foo";
char *end = begin + 4;
if (end - begin != 4)
return 1;
return 0;
}

View file

@ -0,0 +1,69 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
char *g_hello = "hello";
char g_arena[4] = "XXX";
char *g_chars = g_arena;
int
main ()
{
if (*g_hello != 'h')
return 1;
if (g_hello[0] != 'h')
return 2;
if (g_chars[0] != 'X')
return 3;
if (*g_chars != 'X')
return 4;
g_arena[0] = 'A';
if (*g_chars != 'A')
return 5;
char *x = g_arena;
if (*x++ != 'A')
return 5;
*x++ = 'C';
if (g_chars[1] != 'C')
return 7;
if (g_chars[2] != 'X')
return 8;
*--x = 'X';
if (g_chars[1] != 'X')
return 9;
char **pp = &x;
if (**pp != 'X')
return 10;
char *p = *pp;
if (*p != 'X')
return 11;
char ***ppp = &pp;
if (***ppp != 'X')
return 12;
char **pp2 = *ppp;
if (**pp2 != 'X')
return 13;
return 0;
}

View file

@ -0,0 +1,26 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
_exit (0);
return 1;
}

View file

@ -0,0 +1,26 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int
main ()
{
_exit (42);
return 0;
}

View file

@ -0,0 +1 @@
42

View file

@ -0,0 +1,47 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
long
wrap (long a)
{
//eputs ("wrap:"); eputs (itoa (a)); eputs ("\n");
return a;
}
int
print (int a)
{
//eputs ("print:"); eputs (itoa (a)); eputs ("\n");
return a;
}
int
main ()
{
int a[2] = { 101, -1 };
//eputs ("b:"); eputs (itoa (a[0])); eputs ("\n");
int r = wrap (print (a[0]));
if (r != 101)
return 1;
return 0;
}

View file

@ -0,0 +1,267 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
isid (char c)
{
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_';
}
int
main (int c)
{
int f = 0;
int t = 1;
int one = t;
oputs ("\n");
oputs ("t: if (f)\n");
if (f)
return 1;
oputs ("t: if (one != 1)\n");
if (one != 1)
return 2;
oputs ("t: if (1 != one)\n");
if (1 != one)
return 3;
oputs ("t: if (one > 1)\n");
if (one > 1)
return 4;
oputs ("t: if (one < 0)\n");
if (one < 0)
return 5;
oputs ("t: if (one <= 0)\n");
if (one <= 0)
return 6;
oputs ("t: if (one >= 2)\n");
if (one >= 2)
return 7;
oputs ("t: if (!1)\n");
if (!1)
return 8;
oputs ("t: if (one == 0)\n");
if (one == 0)
return 9;
oputs ("t: if (f != 0)\n");
if (one != 1)
return 10;
oputs ("t: if (1)\n");
if (1)
goto ok0;
return 111;
ok0:
oputs ("t: if (0); return 1; else;\n");
if (0)
return 12;
else
goto ok1;
ok1:
oputs ("t: if (t)\n");
if (t)
goto ok2;
return 13;
ok2:
oputs ("t: if (one > 0)\n");
if (one > 0)
goto ok3;
return 14;
ok3:
oputs ("t: if (one < 2)\n");
if (one < 2)
goto ok4;
return 15;
ok4:
oputs ("t: if (one >= 0)\n");
if (one >= 0)
goto ok5;
return 16;
ok5:
oputs ("t: if (one >= 1)\n");
if (one >= 0)
goto ok6;
return 17;
ok6:
oputs ("t: if (one <= 2)\n");
if (one <= 2)
goto ok7;
return 18;
ok7:
oputs ("t: if (one <= 1)\n");
if (one <= 1)
goto ok8;
return 19;
ok8:
oputs ("t: if (!0)\n");
if (!0)
goto ok9;
return 20;
ok9:
oputs ("t: if (one == 1)\n");
if (one == 1)
goto ok10;
return 21;
ok10:
oputs ("t: if (one != 0)\n");
if (one != 0)
goto ok11;
return 22;
ok11:
;
int m1 = -1;
int i;
oputs ("t: i = one > 0\n");
i = one > 0;
if (!i)
return 23;
oputs ("t: i = one >= 1\n");
i = one >= 1;
if (!i)
return 24;
oputs ("t: i = one < 2\n");
i = one < 2;
if (!i)
return 25;
oputs ("t: i = one <= 1\n");
i = one <= 1;
if (!i)
return 26;
oputs ("t: i = 0 > one\n");
i = 0 > one;
if (i)
return 27;
oputs ("t: i = 0 >= one\n");
i = 0 >= one;
if (i)
return 28;
oputs ("t: i = 1 < one \n");
i = 1 < one;
if (i)
return 29;
oputs ("t: i = 2 <= one\n");
i = 2 <= one;
if (i)
return 30;
oputs ("t: i = m1 > -2\n");
i = m1 > -2;
if (!i)
return 31;
oputs ("t: i = m1 >= -1\n");
i = m1 >= -1;
if (!i)
return 32;
oputs ("t: i = m1 < 0\n");
i = m1 < 0;
if (!i)
return 33;
oputs ("t: i = m1 <= -1\n");
i = m1 <= -1;
if (!i)
return 34;
oputs ("t: i = -1 > m1\n");
i = -1 > m1;
if (i)
return 35;
oputs ("t: i = -2 >= m1\n");
i = -2 >= m1;
if (i)
return 36;
oputs ("t: i = -1 < m1 \n");
i = -1 < m1;
if (i)
return 37;
oputs ("t: i = -2 <= m1\n");
i = 0 <= m1;
if (i)
return 38;
oputs ("t: isid (0)\n");
if (isid (0))
return 39;
oputs ("t: isid (6)\n");
if (isid (6))
return 40;
oputs ("t: isid (a)\n");
if (isid ('a') != 1)
return 41;
oputs ("t: isid ( )\n");
if (isid (' '))
return 42;
return 0;
}

View file

@ -0,0 +1,60 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
main ()
{
int f = 0;
int t = 1;
int one = t;
oputs ("\n");
oputs ("t: if (1 && 0)\n");
if (1 && 0)
return 1;
oputs ("t: if (!t && f)\n");
if (!t && f)
return 1;
oputs ("t: if (t && !one)\n");
if (t && !one)
return 1;
oputs ("t: if (f || !t)\n");
if (f || !t)
return 1;
oputs ("t: if (1 && !0)\n");
if (1 && !0)
goto ok0;
return 1;
ok0:
oputs ("t: if (f || t)\n");
if (f || t)
goto ok1;
return 1;
ok1:
return 0;
}

View file

@ -0,0 +1,63 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
main ()
{
int f = 0;
int t = 1;
int one = t;
int i = 0;
oputs ("\n");
oputs ("t: if (i++)\n");
if (i++)
return 1;
oputs ("t: if (--i)\n");
if (--i)
return 1;
oputs ("t: i += 2\n");
i += 2;
if (i != 2)
return 1;
oputs ("t: i -= 2\n");
i -= 2;
if (i != 0)
return 1;
oputs ("t: if (++i)\n");
if (++i)
goto ok0;
return 1;
ok0:
oputs ("t: if (i--)\n");
if (i--)
goto ok1;
return 1;
ok1:
return 0;
}

View file

@ -0,0 +1,103 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
char g_arena[10];
char *g_chars = g_arena;
int
main ()
{
int i = 0;
char c = 'C';
char *p = "mes";
char *x = g_arena;
char *y = g_chars;
oputs ("\n");
oputs ("t: p[0] != 'm'\n");
if (p[0] != 'm')
return p[0];
oputs ("t: p[i] != 't'\n");
if (p[i] != 'm')
return p[i];
oputs ("t: *g_chars != 'A'\n");
g_arena[0] = 'A';
if (*g_chars != 'A')
return 1;
oputs ("t: *x != 'A'\n");
if (*x != 'A')
return 1;
oputs ("t: *y != 'A'\n");
if (*y != 'A')
return 1;
oputs ("t: *x != 'Q'\n");
g_chars[0] = 'Q';
if (*x != 'Q')
return 1;
oputs ("t: *x++ != 'C'\n");
*x++ = c;
if (*g_chars != 'C')
return 1;
oputs ("t: *g_chars == 'B'\n");
g_arena[0] = 'B';
if (*g_chars == 'B')
goto ok1;
return 1;
ok1:
oputs ("t: *x == 'B'\n");
x = g_arena;
if (*x == 'B')
goto ok2;
return 1;
ok2:
oputs ("t: *y == 'B'\n");
y = g_chars;
if (*y == 'B')
goto ok3;
return 1;
ok3:
oputs ("t: *x == 'R'\n");
g_chars[0] = 'R';
if (*x == 'R')
goto ok4;
return 1;
ok4:
oputs ("t: *x++ == 'C'\n");
*x++ = c;
if (*g_chars == 'C')
goto ok5;
return 1;
ok5:
return 0;
}

View file

@ -0,0 +1,48 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
main ()
{
oputs ("\n");
oputs ("t: 1 + 2\n");
if (1 + 2 != 3)
return 1;
oputs ("t: 2 - 1\n");
if (0)
return 1;
oputs ("t: 1 << 3\n");
if (1 << 3 != 8)
return 1;
oputs ("t: 8 >> 3\n");
if (8 >> 3 != 1)
return 1;
oputs ("t: 8 / 4\n");
if (8 / 4 != 2)
return 1;
return 0;
}

View file

@ -0,0 +1,48 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
main ()
{
int f = 0;
int t = 1;
int one = t;
oputs ("\n");
oputs ("t: if (f = 0) ?\n");
if (f = 0)
return 1;
oputs ("t: if (!(t = 1)) ?\n");
if (!(t = 1))
return 1;
oputs ("t: if ((f = 0) != 0) ?\n");
if ((f = 0) != 0)
return 1;
oputs ("t: if ((t = 1) != 1) ?\n");
if ((t = 1) != 1)
return 1;
return 0;
}

View file

@ -0,0 +1,42 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
add (int a, int b)
{
return a + b;
}
int
identity (int i)
{
return i;
}
int
main ()
{
if (add (identity (1), identity (2)) != 3)
return 1;
return 0;
}

View file

@ -0,0 +1,42 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
add (int a, int b)
{
return a + b;
}
int
inc (int i)
{
return i + 1;
}
int
main ()
{
if (add (inc (0), inc (1)) != 3)
return 1;
return 0;
}

View file

@ -0,0 +1,116 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
enum type_t
{ TCHAR, TCLOSURE, TCONTINUATION, TFUNCTION, TKEYWORD, TMACRO, TNUMBER, TPAIR, TREF, TSPECIAL, TSTRING,
TSYMBOL, TVALUES, TVECTOR, TBROKEN_HEART };
int
add (int a, int b)
{
return a + b;
}
int
inc (int i)
{
return i + 1;
}
int
identity (int i)
{
return i;
}
int
main ()
{
int i = 0;
int f = 0;
int t = 1;
int one = t;
char *p = "mes";
oputs ("\n");
oputs ("t: if (strlen (\"\"))\n");
if (strlen (""))
return 1;
oputs ("t: if (strlen (p) != 3)\n");
if (strlen (p) != 3)
return 2;
oputs ("t: if (!strlen (\".\"))\n");
if (!strlen ("."))
return 3;
oputs ("t: identity (p[i]) != 'm'\n");
if (identity (p[i]) != 'm')
return identity (p[i]);
oputs ("t: inc (0)\n");
if (inc (0) != 1)
return 4;
oputs ("t: inc (inc (0))\n");
if (inc (inc (0)) != 2)
return 5;
oputs ("t: inc (inc (inc (0)))\n");
if (inc (inc (inc (0))) != 3)
return 6;
oputs ("t: add (1, 2)\n");
if (add (1, 2) != 3)
return 7;
// broken x86, x86_64
oputs ("t: add (inc (0), inc (1))\n");
if (add (inc (0), inc (1)) != 3)
return 8;
// end broken x86, x86_64
oputs ("t: add (TSTRING, 3)\n");
if (add (TSTRING, 3) != 13)
return 9;
// broken x86_64
oputs ("t: add (inc (inc (0)), inc (inc (1)))\n");
if (add (inc (inc (0)), inc (inc (1))) != 5)
return 10;
// end broken x86_64
oputs ("t: if (strlen (\".\"))\n");
if (strlen ("."))
goto ok1;
return 11;
ok1:
oputs ("t: if (strlen (p) == 3)\n");
if (strlen (p) == 3)
goto ok2;
return 12;
ok2:
return 0;
}

View file

@ -0,0 +1,42 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
main ()
{
int i = 0;
oputs ("\n");
if (i)
return 1;
else
oputs ("t: else 1\n");
if (i)
oputs ("0");
else if (i == 1)
oputs ("1");
else
oputs ("t: else if 2\n");
return 0;
}

View file

@ -0,0 +1,47 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
main ()
{
int f = 0;
int t = 1;
int one = t;
oputs ("\n");
oputs ("t: (one == 1) ?\n");
(one == 1) ? 1 : exit (1);
oputs ("t: (f) ?\n");
(f) ? exit (2) : 1;
int r = f ? 3 - 1 : 2 - 2;
if (r)
return 3;
r = t ? 2 + 3 - 1 : 3 + 4 - 5;
if (r != 4)
return 4;
oputs ("t: f ? 3 - 1 : 2 - 2\n");
return f ? 3 - 1 : 2 - 2;
}

View file

@ -0,0 +1,47 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
label (int c)
{
label:
if (c == 0)
return c;
c--;
goto label;
return 1;
}
int
main ()
{
int f;
int t = 1;
int one = t;
oputs ("\n");
oputs ("t: goto label\n");
if (label (1) != 0)
return 1;
return 0;
}

View file

@ -0,0 +1,90 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
int
main ()
{
int i = 0;
int f = 0;
int t = 1;
int one = t;
char *p = "mes";
oputs ("\n");
oputs ("t: for (i=1; i<5; ++i)\n");
for (i = 1; i < 5; ++i)
;
if (i != 5)
return i;
oputs ("t: while (i<3) i++\n");
i = 1;
while (i < 3)
i++;
if (i != 3)
return i;
oputs ("t: do i-- while (i>0)\n");
do
i--;
while (i > 0)
;
if (i != 0)
return 1;
oputs ("t: while (1) break;\n");
while (1)
break;
oputs ("t: while (1) ... break;\n");
while (1)
{
f = 0;
break;
}
oputs ("t: while (1) {while (1) break;break;}\n");
while (1)
{
while (1)
break;
break;
}
oputs ("t: while () {continue;...}\n");
while (one--)
{
continue;
one = 1;
}
one += 2;
oputs ("t: while (1) { goto label; };\n");
while (1)
{
goto ok1;
}
ok1:
return 0;
}

View file

@ -0,0 +1,47 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
int
main ()
{
int r;
int i = 2;
switch (i)
{
// case 0:
// r = 0;
// break;
// case 1:
// r = 1;
// break;
case 2:
r = 2;
default:
r++;
break;
}
if (r != 3)
return 1;
return 0;
}

View file

@ -0,0 +1,46 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
int
main ()
{
int r;
int i = 2;
switch (i)
{
// case 0:
// r = 0;
// break;
// case 1:
// r = 1;
// break;
case 2:
default:
r = 2;
break;
}
if (r != 2)
return 1;
return 0;
}

View file

@ -0,0 +1,174 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
enum type_t
{ TCHAR, TCLOSURE, TCONTINUATION, TFUNCTION, TKEYWORD, TMACRO, TNUMBER, TPAIR, TREF, TSPECIAL, TSTRING,
TSYMBOL, TVALUES, TVECTOR, TBROKEN_HEART };
int
swits (int c)
{
int x = -1;
switch (c)
{
case TCHAR:
{
oputs ("TCHAR\n");
goto next;
}
case 1:
{
oputs ("1\n");
goto next;
}
case 2:
{
oputs ("2\n");
goto next;
}
default:
{
oputs ("default\n");
goto next;
}
}
return 1;
next:
switch (c)
{
case 0:
{
oputs ("0\n");
x = 0;
c = 34;
break;
}
case 5:
case 4:
case 3:
case 2:
case -1:
case 1:
oputs ("5..1, -1\n");
x = 1;
break;
default:
oputs ("default\n");
x = 2;
x = 2;
break;
}
return x;
}
int
default_first (int c)
{
int a;
switch (c)
{
here:
default:
a = 1;
{
}
a = 2;
return a;
there:
case 0:
;
{
}
return 0;
}
return -1;
}
int
main ()
{
oputs ("\n");
oputs ("t: switch 0\n");
int i = swits (0);
if (i != 0)
return i;
oputs ("t: switch 1\n");
if (swits (1) != 1)
return 10;
oputs ("t: switch -1\n");
if (swits (-1) != 1)
return 11;
oputs ("t: switch -1\n");
if (swits (-2) != 2)
return 12;
if (default_first (1) != 2)
return 13;
if (default_first (0) != 0)
return 14;
i = 15;
switch (i)
{
case 0:
case 1:
case 2:
case 3:
case 4:
i = 15;
break;
}
if (i != 15)
return 15;
i = 16;
switch (i)
{
case 1:
default:
case 0:
i = 0;
break;
}
if (i != 0)
return 16;
i = 2;
switch (i)
{
default:
case 0:
i = 17;
break;
case 2:
i = 0;
}
return i;
}

View file

@ -0,0 +1,36 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib-mini.h>
void
void_func ()
{
}
int
main ()
{
oputs ("\n");
oputs ("void_func ()\n");
void_func ();
return 0;
}

View file

@ -0,0 +1,39 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int bar;
static int i = 2;
int baz;
int
test ()
{
static int i = 1;
static int foo = 0;
foo = 0;
return foo - i--;
}
int
main ()
{
test ();
return i - 2 - test ();
}

View file

@ -0,0 +1,37 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
int g_time = 1;
#if __TINYC__
#define time time_
#endif
int *
time ()
{
return &g_time;
}
int
main ()
{
return *time () - 1;
}

View file

@ -0,0 +1,43 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#if __TINYC__
#define unsigned
#endif
static int sint;
static int sint2, sint3;
typedef unsigned int size;
static void *
test (size u)
{
void *r;
if (u)
r = test (u);
}
static int i = 2;
int
main ()
{
void (*foo) () = &test;
test (0);
return 0;
}

View file

@ -0,0 +1,33 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
int
main ()
{
int **p = 1;
int **q = -1;
oputs ("p - q");
oputs (itoa (p - q));
oputs ("\n");
return 0;
}

View file

@ -0,0 +1,36 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <stdio.h>
#include <string.h>
int
main (int argc, char *argv[])
{
oputs ("argc=");
oputs (itoa (argc));
oputs ("\n");
if (argc != 5)
return 1;
return 0;
}

View file

@ -0,0 +1,51 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <stdio.h>
#include <string.h>
int
main (int argc, char *argv[])
{
oputs ("\n");
oputs ("t: argv[0] == \"lib/tests/scaffold....\"\n");
oputs ("argv0=");
oputs (argv[0]);
oputs ("\n");
if (strcmp (argv[0], "lib/tests/scaffold/54-argv"))
return 1;
oputs ("t: *argv\"\n");
oputs (*argv);
oputs ("\n");
if (argc != 5)
return 2;
if (strcmp (argv[1], "-s"))
return 3;
if (strcmp (argv[2], "--long"))
return 4;
return 0;
}

View file

@ -0,0 +1,90 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <mes/lib-mini.h>
char g_hello[] = "hello\n" "world\n";
char *g_hello2 = "hello\n" "world\n";
char g_hello3[] = {
'h', 'e', 'l', 'l', 'o', '\n',
'w', 'o', 'r', 'l', 'd', '\n',
'\0',
}
;
int g_hello_int[] = { 0, 1, 2, 3, 4, 5 };
int
main (int argc)
{
oputs ("0:"); oputs (g_hello); oputs ("\n");
oputs ("2:"); oputs (g_hello2); oputs ("\n");
oputs ("3:"); oputs (g_hello3); oputs ("\n");
if (strcmp (g_hello, g_hello2))
return 1;
if (strcmp (g_hello, g_hello3))
return 2;
char hello[] =
"hello\n"
"world\n"
;
char *hello2 =
"hello\n"
"world\n"
;
oputs (hello);
oputs (hello2);
if (strcmp (hello, hello2))
return 3;
char hello3[] =
{
'h', 'e', 'l', 'l', 'o', '\n',
'w', 'o', 'r', 'l', 'd', '\n',
'\0',
}
;
oputs (hello3);
if (strcmp (hello, hello3))
return 4;
if (g_hello_int[0])
return 5;
if (g_hello_int[1] != 1)
return 6;
int hello_int[] = {0, 1, 2, 3, 4, 5};
if (hello_int[0])
return 7;
if (hello_int[1] != 1)
return 8;
return 0;
}

View file

@ -0,0 +1,206 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <mes/lib.h>
int
add (int a, int b)
{
return a + b;
}
int
inc (int i)
{
return i + 1;
}
int
main ()
{
int i;
oputs ("\n");
oputs ("t: 0 < 0\n");
if (0 < 0)
return 1;
oputs ("t: 2 < 1\n");
if (2 < 1)
return 2;
oputs ("t: -1 < -2\n");
if (-1 < -2)
return 3;
oputs ("t: 0 < -1\n");
if (0 < -1)
return 4;
oputs ("t: 0 > 0\n");
if (0 > 0)
return 5;
oputs ("t: 1 > 2\n");
if (1 > 2)
return 6;
oputs ("t: -2 > -1\n");
if (-2 > -1)
return 7;
oputs ("t: -1 > 0\n");
if (-1 > 0)
return 9;
oputs ("t: 1 == inc (0)\n");
if (1 == inc (0))
goto ok0;
return 10;
ok0:
oputs ("t: 0 < inc (0)\n");
if (0 < inc (0))
goto ok1;
return 11;
ok1:
oputs ("t: inc (0) + 2 != 3\n");
if (inc (0) + inc (1) != 3)
return 12;
oputs ("t: 4/2=");
i = 4 / 2;
if (i != 2)
return 13;
i += 48;
putchar (i);
oputs ("\n");
oputs ("t: 3*4=\n");
i = 3 * 4;
if (i != 12)
return 14;
oputs ("t: i /= 4\n");
i /= 4;
if (i != 3)
return 15;
oputs ("t: i *= 4\n");
i *= 4;
if (i != 12)
return 16;
oputs ("t: 1 << 3\n");
if (1 << 3 != 8)
return 1 << 3;
oputs ("t: 3 << 4\n");
if (3 << 4 != 48)
return 3 << 4;
oputs ("t: 48 >> 3\n");
if (48 >> 4 != 3)
return 48 >> 4;
oputs ("t: 10 >> 1\n");
if (10 >> 1 != 5)
return 10 >> 1;
oputs ("t: 1 | 4\n");
if ((1 | 4) != 5)
return 1 | 4;
i = -3;
oputs ("t: -i\n");
if (-i != 3)
return 22;
oputs ("t: -1 + 2\n");
if (-1 + 2 != 1)
return 23;
oputs ("t: 1 & 3\n");
if ((1 & 3) != 1)
return 24;
oputs ("t: ~0\n");
if (~0 != -1)
return 25;
oputs ("t: 1 | 3\n");
if ((1 | 2) != 3)
return 26;
oputs ("t: ^ 1 \n");
if ((1 ^ 3) != 2)
return 27;
oputs ("t: 3 == 3\n");
if ((3 == 3) != 1)
return 28;
oputs ("t: 3 != 3\n");
if ((3 != 3) != 0)
return 29;
oputs ("t: 011 == 15\n");
if (011 != 9)
return 30;
oputs ("t: 0b11 == 3\n");
if (0b11 != 3)
return 31;
oputs ("t: 0x11 == 3\n");
if (0x11 != 17)
return 32;
oputs ("t: i = INT_MAX\n");
i = INT_MAX;
if (strcmp ("2147483647", itoa (i)))
return 33;
oputs ("t: i = 2147483646\n");
i = 2147483646;
oputs ("t: i++\n");
i++;
oputs ("t: i = INT_MIN\n");
i = INT_MIN;
if (strcmp ("-2147483648", itoa (i)))
return 34;
oputs ("t: i = -2147483647\n");
i = -2147483647;
oputs ("t: i--\n");
i--;
return 0;
}

View file

@ -0,0 +1,150 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *env[] = { "foo", "bar", "baz", 0 };
#if 0 //!SYSTEM_LIBC
#define getenv xgetenv
char *
getenv (char const *s)
{
eputs ("getenv\n");
char **p = environ;
int length = strlen (s);
eputs ("getenv length=");
eputs (itoa (length));
eputs ("\n");
while (*p)
{
eputs ("*p=");
eputs (*p);
eputs ("\n");;
eputs (" p=");
eputs (itoa ((long) p));
eputs ("\n");
if (!strncmp (s, *p, length) && *(*p + length) == '=')
return (*p + length + 1);
p++;
}
return 0;
}
#endif
int
test (char **e)
{
int i = 0;
oputs ("\n");
oputs ("a[i] = i-1\n");
int a[3];
for (int i = 0; i < 3; i++)
a[i] = i - 1;
for (int i = 0; i < 3; i++)
if (a[i] != i - 1)
return 1;
oputs ("env [");
oputs (itoa ((long) env));
oputs ("]\n");
oputs ("e [");
oputs (itoa ((int) e));
oputs ("]\n");
oputs ("env [0] == \"foo\"\n");
if (strcmp (env[0], "foo"))
return 2;
oputs ("env [1] == \"bar\"\n");
if (strcmp (env[1], "bar"))
return 3;
oputs ("t: **p in *env[]\n");
char **pp = env;
while (*pp)
{
oputs ("pp [");
oputs (itoa ((int) pp));
oputs ("]: ");
if (*pp)
oputs (*pp);
oputs ("\n");
pp++;
i++;
}
if (i != 3)
return i;
pp = env;
oputs ("t: *pp++ == \"foo\"\n");
if (strcmp (*pp++, "foo"))
return 4;
oputs ("t: *pp++ == \"bar\"\n");
if (strcmp (*pp++, "bar"))
return 5;
char *buf = "hello";
oputs ("t: buf[0]\n");
if (buf[0] != 'h')
return 6;
oputs ("t: buf + 1\n");
if (*(buf + 1) != 'e')
return 7;
char **p = &buf;
oputs ("t: **p\n");
if (**p != 'h')
return 8;
oputs ("t: *(p + 1)\n");
if (*(*p + 1) != 'e')
return 9;
oputs ("t: getenv ()\n");
if (!getenv ("PATH"))
return 10;
oputs ("t: setenv ()\n");
if (setenv ("61-array", "yes", 1))
return 11;
oputs ("t: getenv2 ()\n");
if (strcmp (getenv ("61-array"), "yes"))
return 12;
return 0;
}
int
main (int argc, char *argv[])
{
return test (env);
}

View file

@ -0,0 +1,59 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
int one_two_three[3] = {
1, 2, 3
};
char *foo_bar_baz[3] = {
"foo", "bar", "baz"
};
char foo_bar_baz_haha[3][4] = {
"foo", "bar", "baz"
};
char *foo = "foo";
char *bar = "bar";
char *baz = "baz";
char *foo_bar_baz_mwhuhahaha[3] = {
&foo, &bar, &baz
};
int
main ()
{
puts ("one:");
puts (itoa (one_two_three[0]));
puts ("\n");
puts ("foo:");
puts (foo_bar_baz[1]);
puts ("\n");
puts ("bar:");
puts (foo_bar_baz_haha[2]);
puts ("\n");
char *p = foo_bar_baz_haha[2];
puts ("baz:");
puts (p);
puts ("\n");
return strcmp (foo_bar_baz[2], "baz");
}

View file

@ -0,0 +1,75 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
struct scm
{
int type;
int car;
int cdr;
};
char g_arena[24];
struct scm *g_cells = (struct scm *) g_arena;
int
main ()
{
g_cells[0].type = 0;
g_cells[0].car = -1;
g_cells[1].cdr = 0;
g_cells[1].type = -1;
g_cells[1].car = 0;
g_cells[1].cdr = -1;
if (g_cells[0].type)
return 1;
if (g_cells[0].car != -1)
return 2;
if (g_cells[0].cdr)
return 3;
if (g_cells[1].type != -1)
return 4;
if (g_cells[1].car)
return 5;
if (g_cells[1].cdr != -1)
return 6;
g_cells[0] = g_cells[1];
if (g_cells[0].type != -1)
return 7;
if (g_cells[0].car)
return 8;
if (g_cells[0].cdr != -1)
return 9;
return 0;
}

View file

@ -0,0 +1,51 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
struct scm
{
int type;
int car;
int cdr;
};
char g_arena[24];
struct scm *g_cells = (struct scm *) g_arena;
int
main ()
{
g_cells[0].type = -1;
g_cells[0].car = 0;
g_cells[0].cdr = 0;
g_cells[1].type = -1;
g_cells[1].car = 0;
g_cells[1].cdr = 0;
oputs ("t: TYPE (0) != TYPE (1)\n");
if (g_cells[0].type == g_cells[1].type)
goto ok;
return 1;
ok:
return 0;
}

View file

@ -0,0 +1,51 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
struct scm
{
int type;
int car;
int cdr;
};
char g_arena[12];
struct scm *g_cells = (struct scm *) g_arena;
int
main ()
{
g_cells[0].type = -1;
g_cells[0].car = 0;
g_cells[0].cdr = -1;
if (g_cells[0].type != -1)
return 1;
if (g_cells[0].car)
return 2;
if (g_cells[0].cdr != -1)
return 3;
return 0;
}

View file

@ -0,0 +1,49 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
struct scm
{
int type;
int car;
int cdr;
};
struct scm a = { -1, 0, -1 };
struct scm b = { 0, -1, 0 };
int
main ()
{
a = b;
if (a.type)
return 1;
if (a.car != -1)
return 2;
if (a.cdr)
return 3;
return 0;
}

View file

@ -0,0 +1,313 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
add (int a, int b)
{
return a + b;
}
int
inc (int i)
{
return i + 1;
}
struct scm
{
int type;
int car;
int cdr;
};
int bla = 1234;
char g_arena[84];
#if __MESC__
struct scm *g_cells = g_arena;
#else
struct scm *g_cells = (struct scm *) g_arena;
#endif
char *g_chars = g_arena;
int
foo ()
{
oputs ("t: foo\n");
return 0;
};
int
bar (int i)
{
oputs ("t: bar\n");
return 0;
};
struct function
{
int (*function) (void);
int arity;
//long arity;
char *name;
};
struct function g_fun = { &exit, 1, "fun" };
struct function g_foo = { &foo, 0, "foo" };
struct function g_bar = { &bar, 1, "bar" };
void *functions[2];
//int functions[2];
struct function g_functions[2];
int g_function = 0;
enum type_t
{ TCHAR, TCLOSURE, TCONTINUATION, TFUNCTION, TKEYWORD, TMACRO, TNUMBER, TPAIR, TREF, TSPECIAL, TSTRING,
TSYMBOL, TVALUES, TVECTOR, TBROKEN_HEART };
typedef int SCM;
int g_free = 3;
SCM tmp;
SCM tmp_num;
int ARENA_SIZE = 200;
#define TYPE(x) g_cells[x].type
#define CAR(x) g_cells[x].car
#define CDR(x) g_cells[x].cdr
#define VALUE(x) g_cells[x].cdr
#define CAAR(x) CAR (CAR (x))
struct scm scm_fun = { TFUNCTION, 0, 0 };
SCM cell_fun;
int
main ()
{
oputs ("\n");
oputs ("t: g_cells[0] = g_cells[1]\n");
TYPE (1) = 1;
CAR (1) = 2;
CDR (1) = 3;
g_cells[0] = g_cells[1];
if (TYPE (0) != 1)
return 1;
if (CAR (0) != 2)
return 2;
if (CDR (0) != 3)
return 3;
oputs ("t: g_cells[i] = g_cells[j]\n");
int i = 0;
int j = 1;
TYPE (1) = 4;
CAR (1) = 5;
CDR (1) = 6;
g_cells[i] = g_cells[j];
if (TYPE (0) != 4)
return 4;
if (CAR (0) != 5)
return 5;
if (CDR (0) != 6)
return 6;
oputs ("t: g_cells[0+add(0,0] = g_cells[0+inc(0)]\n");
TYPE (1) = 1;
CAR (1) = 2;
CDR (1) = 3;
g_cells[0 + add (0, 0)] = g_cells[0 + inc (0)];
if (TYPE (0) != 1)
return 7;
if (CAR (0) != 2)
return 9;
if (CDR (0) != 3)
return 9;
g_cells[0].type = TNUMBER;
g_cells[0].car = 0;
g_cells[0].cdr = 0;
g_cells[1].type = TNUMBER;
g_cells[1].car = 0;
g_cells[1].cdr = 0;
oputs ("t: TYPE (0) == TYPE (1)\n");
if (TYPE (0) == TYPE (1))
goto ok;
return 10;
ok:
g_cells[0].car = 1;
g_cells[1].car = 2;
oputs ("t: int c = VALUE (0)\n");
int c = CAR (0);
if (c != 1)
return 11;
oputs ("t: CAAR (0) != 2\n");
if (CAAR (0) != 2)
return 12;
oputs ("t: 2 != CAAR (0)\n");
if (2 != CAAR (0))
return 13;
g_cells[3].type = 0x64;
if (g_cells[3].type != 0x64)
return g_cells[3].type;
TYPE (4) = 4;
if (TYPE (4) != 4)
return 14;
CDR (3) = 0x22;
CDR (4) = 0x23;
if (CDR (3) != 0x22)
return 15;
oputs ("t: g_fun.arity != 1;\n");
if (g_fun.arity != 1)
return 16;
oputs ("t: g_fun.function != exit;\n");
if (g_fun.function != &exit)
return 17;
oputs ("t: struct fun = {&exit,1,\"exit\"};\n");
struct function fun = { &exit, 1, "exit" };
oputs ("t: fun.arity != 1;\n");
if (fun.arity != 1)
return 18;
oputs ("t: fun.function != exit;\n");
if (fun.function != &exit)
return 19;
oputs ("t: oputs (fun.name)\n");
if (strcmp (fun.name, "exit"))
return 20;
oputs ("t: oputs (g_fun.name)\n");
if (strcmp (g_fun.name, "fun"))
return 21;
oputs ("t: g_functions[g_function++] = g_foo;\n");
g_functions[g_function++] = g_foo;
oputs ("t: pbar->arity == 1\n");
struct function *barp = &g_bar;
if (barp->arity != 1)
return 22;
int fn = 0;
oputs ("t: g_functions[g_cells[fn].cdr].arity\n");
if (g_functions[g_cells[fn].cdr].arity)
return 23;
if (g_functions[g_cells[fn].cdr].arity != 0)
return 24;
int (*functionx) (void) = 0;
functionx = g_functions[0].function;
oputs ("t: functionx == foo\n");
if (functionx != foo)
return 25;
oputs ("t: g_functions[0].name\n");
if (strcmp (g_functions[0].name, "foo"))
return 26;
oputs ("t: (functionx) () == foo\n");
if ((functionx) () != 0)
return 27;
oputs ("t: g_functions[<foo>].arity\n");
if (g_functions[0].arity != 0)
return 28;
fn++;
g_functions[fn] = g_bar;
g_cells[fn].cdr = fn;
if (g_cells[fn].cdr != fn)
return 29;
oputs ("t: g_functions[g_cells[fn].cdr].function\n");
functionx = g_functions[g_cells[fn].cdr].function;
oputs ("t: g_functions[1].name\n");
if (strcmp (g_functions[1].name, "bar"))
return 30;
oputs ("t: functionx == bar\n");
if (functionx != bar)
return 31;
oputs ("t: (functiony) (1) == bar\n");
int (*functiony) (int) = 0;
functiony = g_functions[g_cells[fn].cdr].function;
if ((functiony) (1) != 0)
return 32;
oputs ("t: g_functions[<bar>].arity\n");
if (g_functions[fn].arity != 1)
return 33;
// fake name
scm_fun.car = 33;
scm_fun.cdr = g_function;
g_function++;
oputs ("fun");
g_functions[g_function] = g_fun;
cell_fun = g_free++;
g_cells[cell_fun] = scm_fun;
oputs ("t: TYPE (cell_fun)\n");
if (TYPE (cell_fun) != TFUNCTION)
return 34;
oputs ("t: CAR (cell_fun)\n");
if (CAR (cell_fun) != 33)
return 35;
// FIXME!
// oputs ("t: CDR (cell_fun)\n");
// if (CDR (cell_fun) != g_function)
// return 36;
return 0;
}

View file

@ -0,0 +1,45 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <stdlib.h>
struct function
{
int (*function) (void);
int arity;
char *name;
};
struct function g_fun = { &exit, 1, "fun" };
int functions[2];
int g_function = 0;
struct function g_functions[2];
int
main ()
{
g_function++;
oputs ("fun");
g_functions[g_function] = g_fun;
return 0;
}

View file

@ -0,0 +1,45 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
struct scm
{
int type;
int car;
int cdr;
};
int
main ()
{
struct scm a = { -1, 0, -1 };
if (a.type != -1)
return 1;
if (a.car)
return 2;
if (a.cdr != -1)
return 3;
return 0;
}

View file

@ -0,0 +1,47 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
struct scm
{
int type;
int car;
int cdr;
};
struct scm a = { -1, 0, -1 };
struct scm *p = &a;
int
main ()
{
if (p->type != -1)
return 1;
if (p->car)
return 2;
if (p->cdr != -1)
return 3;
return 0;
}

View file

@ -0,0 +1,45 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
struct scm
{
int type;
int car;
int cdr;
};
struct scm a = { -1, 0, -1 };
int
main ()
{
if (a.type != -1)
return 1;
if (a.car)
return 2;
if (a.cdr != -1)
return 3;
return 0;
}

View file

@ -0,0 +1,162 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct scm
{
int type;
int car;
int cdr;
};
int bla = 1234;
char g_arena[84];
struct scm *g_cells = (struct scm *) g_arena;
char *g_chars = g_arena;
int
foo ()
{
oputs ("t: foo\n");
return 0;
};
int
bar (int i)
{
oputs ("t: bar\n");
return 0;
};
struct function
{
int (*function) (void);
int arity;
char *name;
};
struct function g_fun = { &exit, 1, "fun" };
struct function g_foo = { &foo, 0, "foo" };
struct function g_bar = { &bar, 1, "bar" };
//void *functions[2];
int functions[2];
struct function g_functions[2];
int g_function = 0;
enum type_t
{ TCHAR, TCLOSURE, TCONTINUATION, TFUNCTION, TKEYWORD, TMACRO, TNUMBER, TPAIR, TREF, TSPECIAL, TSTRING,
TSYMBOL, TVALUES, TVECTOR, TBROKEN_HEART };
typedef int SCM;
int g_free = 3;
SCM tmp;
SCM tmp_num;
int ARENA_SIZE = 200;
#define TYPE(x) g_cells[x].type
#define CAR(x) g_cells[x].car
#define CDR(x) g_cells[x].cdr
#define VALUE(x) g_cells[x].cdr
#define CAAR(x) CAR (CAR (x))
struct scm scm_fun = { TFUNCTION, 0, 0 };
SCM cell_fun;
SCM
alloc (int n)
{
oputs ("040\n");
SCM x = g_free;
g_free += n;
return x;
}
SCM
make_cell (SCM type, SCM car, SCM cdr)
{
oputs ("030\n");
SCM x = alloc (1);
TYPE (x) = VALUE (type);
if (VALUE (type) == TCHAR || VALUE (type) == TNUMBER)
{
if (car)
CAR (x) = CAR (car);
if (cdr)
CDR (x) = CDR (cdr);
}
else if (VALUE (type) == TFUNCTION)
{
if (car)
CAR (x) = car;
if (cdr)
CDR (x) = CDR (cdr);
}
else
{
CAR (x) = car;
CDR (x) = cdr;
}
return x;
}
SCM
make_cell_test ()
{
oputs ("010\n");
VALUE (tmp_num) = TPAIR;
oputs ("011\n");
make_cell (tmp_num, 0, 1);
oputs ("012\n");
return 0;
}
SCM
make_tmps_test (struct scm * cells)
{
oputs ("t: tmp = g_free++\n");
tmp = g_free++;
oputs ("t: cells[tmp].type = CHAR\n");
cells[tmp].type = TCHAR;
oputs ("000\n");
tmp_num = g_free++;
oputs ("001\n");
cells[tmp_num].type = TNUMBER;
oputs ("002\n");
return 0;
}
int
main ()
{
oputs ("\n");
make_tmps_test (g_cells);
make_cell_test ();
oputs ("020\n");
return 0;
}

View file

@ -0,0 +1,87 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct scm
{
int type;
int car;
int cdr;
};
char g_arena[84];
#if __MESC__
struct scm *g_cells = g_arena;
#else
struct scm *g_cells = (struct scm *) g_arena;
#endif
char *g_chars = g_arena;
int g = 48;
int
get ()
{
int i = g;
g++;
return i;
}
int
main ()
{
char *p = (char *) g_chars;
int i = 0;
oputs ("\n: ");
oputs ("t: read 0123456789\nt: ");
int c = get ();
while (i < 10)
{
*p++ = c;
putchar (c);
c = get ();
i++;
}
oputs ("\n");
if (strcmp (g_chars, "0123456789"))
return 1;
oputs ("t: fdungetc ('A') == getchar ()\n");
fdungetc ('A', STDIN);
if (getchar () != 'A')
return 2;
oputs ("t: fdungetc (0)\n");
fdungetc (0, STDIN);
if (getchar () != 0)
return 3;
oputs ("t: i == 'm'\n");
char m = 0x1122336d;
i = m;
if (i != 'm')
return 4;
return 0;
}

View file

@ -0,0 +1,113 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define memset xmemset
#define calloc xcalloc
void *
memset (void *s, int c, size_t n)
{
char *p = s;
while (n--)
*p++ = c;
return s;
}
void *
calloc (size_t nmemb, size_t size)
{
size_t count = nmemb * size;
void *p = malloc (count);
memset (p, 0, count);
return p;
}
/* {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'} */
char little_endian_table[16] =
{ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 };
char *
little_endian (unsigned value, char *c, int number_of_bytes)
{
char table[16] =
{ 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46 };
switch (number_of_bytes)
{
case 4:
{
c[6] = table[value >> 28];
c[7] = table[(value >> 24) % 16];
}
case 3:
{
c[4] = table[(value >> 20) % 16];
c[5] = table[(value >> 16) % 16];
}
case 2:
{
c[2] = table[(value >> 12) % 16];
c[3] = table[(value >> 8) % 16];
}
case 1:
{
c[0] = table[(value >> 4) % 16];
c[1] = table[value % 16];
break;
}
default:
return "invalid";
}
return c;
}
int
main ()
{
char table[3] = { '0', '1', '2' };
char *s;
s = calloc (10, sizeof (char));
eputs ("2=");
eputs (little_endian (2, s, 1));
eputs ("\n");
if (strcmp (s, "02"))
return 1;
eputs ("8=");
eputs (little_endian (8, s, 2));
eputs ("\n");
if (strcmp (s, "0800"))
return 2;
eputs ("16=");
eputs (little_endian (16, s, 4));
eputs ("\n");
if (strcmp (s, "10000000"))
return 3;
return 0;
}

View file

@ -0,0 +1,56 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
struct foo
{
int field;
int array[3];
};
struct foo foes[] =
{
{10, {11, 12, 13}},
{20, {21, 22}},
{30, {31}},
{40, {41}},
{0}
};
int
main ()
{
for (struct foo *p = foes; p->field; p++)
{
oputs ("{");
oputs (itoa (p->field)); oputs (",");
oputs ("{");
oputs (itoa (p->array[0])); oputs (",");
oputs (itoa (p->array[1])); oputs (",");
oputs (itoa (p->array[2]));
oputs ("}");
oputs ("},\n");
}
oputs ("{0}\n");
oputs ("};\n");
return 0;
}

View file

@ -0,0 +1,6 @@
{10,{11,12,13}},
{20,{21,22,0}},
{30,{31,0,0}},
{40,{41,0,0}},
{0}
};

View file

@ -0,0 +1,33 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* This file is part of GNU Mes.
*
* GNU Mes is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or (at
* your option) any later version.
*
* GNU Mes is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
char foo[3] = "foo";
extern int baz;
char bar[4] = "bar";
int
main (void)
{
foo[3] = ':';
oputs (foo);
return 0;
}

View file

@ -0,0 +1 @@
foo:bar

Some files were not shown because too many files have changed in this diff Show more