mirror of
https://github.com/fosslinux/live-bootstrap.git
synced 2026-03-15 07:45:24 +01:00
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:
parent
2706e07556
commit
649d7b68dc
1029 changed files with 120985 additions and 18 deletions
45
sysa/mes-0.22/lib/tests/stdio/70-printf-hello.c
Normal file
45
sysa/mes-0.22/lib/tests/stdio/70-printf-hello.c
Normal 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 <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int i = 42;
|
||||
char *s = "mes";
|
||||
char buf[20];
|
||||
|
||||
printf ("i=%d\n", i);
|
||||
sprintf (buf, "i=%d\n", i);
|
||||
if (strcmp (buf, "i=42\n"))
|
||||
return 1;
|
||||
|
||||
printf ("s=%s\n", s);
|
||||
sprintf (buf, "s=%s\n", s);
|
||||
if (strcmp (buf, "s=mes\n"))
|
||||
return 2;
|
||||
|
||||
return 0;
|
||||
}
|
||||
85
sysa/mes-0.22/lib/tests/stdio/70-printf-simple.c
Normal file
85
sysa/mes-0.22/lib/tests/stdio/70-printf-simple.c
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
/* -*-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 <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
char *s = "mes";
|
||||
char c = 'm';
|
||||
int i = 3;
|
||||
char buf[20];
|
||||
|
||||
printf ("c=%c\n", c);
|
||||
sprintf (buf, "c=%c\n", c);
|
||||
if (strcmp (buf, "c=m\n"))
|
||||
return 1;
|
||||
|
||||
if (i != 3)
|
||||
return 2;
|
||||
|
||||
printf ("i=%d\n", i);
|
||||
sprintf (buf, "i=%d\n", i);
|
||||
if (strcmp (buf, "i=3\n"))
|
||||
return 3;
|
||||
|
||||
printf ("s=%s\n", s);
|
||||
sprintf (buf, "s=%s\n", s);
|
||||
if (strcmp (buf, "s=mes\n"))
|
||||
return 4;
|
||||
|
||||
sprintf (buf, "%u", -1);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
|
||||
#if __i386__
|
||||
if (strcmp (buf, "4294967295"))
|
||||
return 5;
|
||||
#elif __x86_64__
|
||||
if (strcmp (buf, "18446744073709551615"))
|
||||
return 6;
|
||||
#endif
|
||||
|
||||
sprintf (buf, ">>%o<<\n", 12);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>14<<\n"))
|
||||
return 7;
|
||||
|
||||
sprintf (buf, ">>%x<<\n", 12);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>c<<\n"))
|
||||
return 8;
|
||||
|
||||
sprintf (buf, ">>%X<<\n", 12);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>C<<\n"))
|
||||
return 9;
|
||||
|
||||
return 0;
|
||||
}
|
||||
191
sysa/mes-0.22/lib/tests/stdio/70-printf.c
Normal file
191
sysa/mes-0.22/lib/tests/stdio/70-printf.c
Normal file
|
|
@ -0,0 +1,191 @@
|
|||
/* -*-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 <string.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
char *s = "mes";
|
||||
char c = 'm';
|
||||
int i = 3;
|
||||
char buf[20];
|
||||
|
||||
printf ("c=%c\n", c);
|
||||
sprintf (buf, "c=%c\n", c);
|
||||
if (strcmp (buf, "c=m\n"))
|
||||
return 1;
|
||||
|
||||
if (i != 3)
|
||||
return 15;
|
||||
printf ("i=%d\n", i);
|
||||
sprintf (buf, "i=%d\n", i);
|
||||
if (strcmp (buf, "i=3\n"))
|
||||
return 2;
|
||||
|
||||
printf ("s=%s\n", s);
|
||||
sprintf (buf, "s=%s\n", s);
|
||||
if (strcmp (buf, "s=mes\n"))
|
||||
return 3;
|
||||
|
||||
sprintf (buf, ">%3d<", 11);
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, "> 11<"))
|
||||
return 4;
|
||||
|
||||
sprintf (buf, ">%03d<", 22);
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, ">022<"))
|
||||
return 5;
|
||||
|
||||
sprintf (buf, ">%-10d<", 33);
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, ">33 <"))
|
||||
return 6;
|
||||
|
||||
sprintf (buf, ">%0d<", 44);
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, ">44<"))
|
||||
return 7;
|
||||
|
||||
printf (">>%.*s<<\n", 5, "hello, world");
|
||||
printf (">>%.*s<<\n", 20, "hello, world");
|
||||
|
||||
printf (">>%.*s<<\n", 10, "foo");
|
||||
printf (">>%*s<<\n", 10, "bar");
|
||||
printf (">>%-*s<<\n", 10, "baz");
|
||||
|
||||
sprintf (buf, "%ld", 42);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, "42"))
|
||||
return 8;
|
||||
|
||||
sprintf (buf, "%u", -1);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
|
||||
#if __i386__
|
||||
if (strcmp (buf, "4294967295"))
|
||||
return 9;
|
||||
#elif __x86_64__
|
||||
if (strcmp (buf, "18446744073709551615"))
|
||||
return 9;
|
||||
#endif
|
||||
|
||||
sprintf (buf, ">>%.5s<<\n", "hello, world");
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>hello<<\n"))
|
||||
return 10;
|
||||
|
||||
sprintf (buf, ">>%.*s<<\n", 5, "hello, world");
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>hello<<\n"))
|
||||
return 11;
|
||||
|
||||
sprintf (buf, ">>%.*s<<\n", 20, "hello, world");
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>hello, world<<\n"))
|
||||
return 12;
|
||||
|
||||
sprintf (buf, ">>%.*s<<\n", 10, "foo");
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>foo<<\n"))
|
||||
return 13;
|
||||
|
||||
sprintf (buf, ">>%*s<<\n", 10, "bar");
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">> bar<<\n"))
|
||||
return 14;
|
||||
|
||||
sprintf (buf, ">>%-*s<<\n", 10, "baz");
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>baz <<\n"))
|
||||
return 15;
|
||||
|
||||
sprintf (buf, ">>%ld<<\n", 12);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>12<<\n"))
|
||||
return 16;
|
||||
|
||||
sprintf (buf, ">>%o<<\n", 12);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>14<<\n"))
|
||||
return 17;
|
||||
|
||||
sprintf (buf, ">>%x<<\n", 12);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>c<<\n"))
|
||||
return 18;
|
||||
|
||||
sprintf (buf, ">>%X<<\n", 12);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, ">>C<<\n"))
|
||||
return 19;
|
||||
|
||||
int n;
|
||||
#if !__x86_64__
|
||||
fprintf (stderr, "foo bar\n%n", &n);
|
||||
if (n != 8)
|
||||
return 20;
|
||||
#endif
|
||||
|
||||
sprintf (buf, "foo%nbar\n", &n);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, "foobar\n"))
|
||||
return 21;
|
||||
if (n != 3)
|
||||
return 22;
|
||||
|
||||
#if !__x86_64__
|
||||
fprintf (stdout, "%12.8d\n", 12345);
|
||||
#endif
|
||||
|
||||
sprintf (buf, "%12.8d\n", 12345);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, " 00012345\n"))
|
||||
return 23;
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
sysa/mes-0.22/lib/tests/stdio/80-sscanf.c
Normal file
44
sysa/mes-0.22/lib/tests/stdio/80-sscanf.c
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* -*-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 <stdarg.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int i;
|
||||
int r = sscanf ("42", "%d", &i);
|
||||
if (r != 1)
|
||||
return 1;
|
||||
if (i != 42)
|
||||
return 2;
|
||||
|
||||
char c;
|
||||
r = sscanf ("foo bar", "foo%cbar", &c);
|
||||
if (r != 1)
|
||||
return 3;
|
||||
if (c != ' ')
|
||||
return 4;
|
||||
|
||||
return 0;
|
||||
}
|
||||
53
sysa/mes-0.22/lib/tests/stdio/90-fopen-append.c
Normal file
53
sysa/mes-0.22/lib/tests/stdio/90-fopen-append.c
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2018 Jeremiah Orians <jeremiah@pdp10.guru>
|
||||
*
|
||||
* 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 <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
FILE *test = fopen ("tmp", "a+");
|
||||
FILE *hold = fopen ("tmp", "r");
|
||||
int a;
|
||||
int b;
|
||||
int i = 1000;
|
||||
do
|
||||
{
|
||||
a = fgetc (test);
|
||||
b = fgetc (hold);
|
||||
fprintf (stdout, "%c == %c\n", a, b);
|
||||
if (i < 1000)
|
||||
{
|
||||
fflush (test);
|
||||
fputc ('a', test);
|
||||
}
|
||||
if (b == EOF)
|
||||
exit (EXIT_SUCCESS);
|
||||
i = i + 1;
|
||||
}
|
||||
while (a == b);
|
||||
fprintf (stderr, "OOOPS you were not supposed to get here\n");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
124
sysa/mes-0.22/lib/tests/stdio/90-fopen.c
Normal file
124
sysa/mes-0.22/lib/tests/stdio/90-fopen.c
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
/* -*-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 <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
dump (char const *name, char const *contents)
|
||||
{
|
||||
unlink (name);
|
||||
FILE *f = fopen (name, "w");
|
||||
fwrite (contents, strlen (contents), 1, f);
|
||||
fclose (f);
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
char *line = "The first line.\n";
|
||||
char *contents = "The first line.\nThe second line.\nThe last line.\n";
|
||||
char *end = "That's all folks!\n";
|
||||
|
||||
char *tmp = "foo";
|
||||
|
||||
dump (tmp, contents);
|
||||
|
||||
FILE *t = fopen (tmp, "r+");
|
||||
if (t <= 0)
|
||||
return 1;
|
||||
|
||||
char buf[80];
|
||||
memset (buf, 0, sizeof (buf));
|
||||
fread (buf, strlen (line), 1, t);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, line))
|
||||
return 2;
|
||||
|
||||
fwrite (end, strlen (end), 1, t);
|
||||
|
||||
fseek (t, 0, SEEK_SET);
|
||||
memset (buf, 0, sizeof (buf));
|
||||
fread (buf, strlen (line), 1, t);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, line))
|
||||
return 3;
|
||||
|
||||
tmp = "bar";
|
||||
dump (tmp, contents);
|
||||
t = fopen (tmp, "w+");
|
||||
if (t <= 0)
|
||||
return 4;
|
||||
|
||||
fwrite (end, strlen (end), 1, t);
|
||||
fseek (t, 0, SEEK_SET);
|
||||
memset (buf, 0, sizeof (buf));
|
||||
fread (buf, strlen (end), 1, t);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, end))
|
||||
return 5;
|
||||
|
||||
fwrite (end, strlen (end), 1, t);
|
||||
|
||||
fseek (t, 0, SEEK_SET);
|
||||
memset (buf, 0, sizeof (buf));
|
||||
fread (buf, strlen (end), 1, t);
|
||||
if (strcmp (buf, end))
|
||||
return 6;
|
||||
|
||||
tmp = "baz";
|
||||
dump (tmp, contents);
|
||||
t = fopen (tmp, "a+");
|
||||
if (t <= 0)
|
||||
return 7;
|
||||
|
||||
fwrite (end, strlen (end), 1, t);
|
||||
fseek (t, 0, SEEK_SET);
|
||||
memset (buf, 0, sizeof (buf));
|
||||
fread (buf, strlen (line), 1, t);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, line))
|
||||
return 8;
|
||||
|
||||
fwrite (end, strlen (end), 1, t);
|
||||
|
||||
fseek (t, 0, SEEK_SET);
|
||||
fread (buf, strlen (line), 1, t);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, line))
|
||||
return 9;
|
||||
|
||||
return 0;
|
||||
}
|
||||
79
sysa/mes-0.22/lib/tests/stdio/90-fread-fwrite.c
Normal file
79
sysa/mes-0.22/lib/tests/stdio/90-fread-fwrite.c
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
/* -*-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 <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
char *temp = "COPYING.tmp";
|
||||
char *new = "COPYING.new";
|
||||
|
||||
unlink (temp);
|
||||
unlink (new);
|
||||
|
||||
FILE *t = fopen (temp, "wb+");
|
||||
FILE *n = fopen (new, "wb");
|
||||
|
||||
char *header = "!<header>\n";
|
||||
fwrite (header, strlen (header), 1, n);
|
||||
|
||||
char *data = "foo bar baz\n";
|
||||
fwrite (data, strlen (data), 1, t);
|
||||
|
||||
fseek (t, 0, SEEK_END);
|
||||
int size = ftell (t);
|
||||
fprintf (stderr, " size=>%d\n", size);
|
||||
fseek (t, 0, SEEK_SET);
|
||||
char *p = (char *) malloc (size + 1);
|
||||
fread (p, size, 1, t);
|
||||
fwrite (p, size, 1, n);
|
||||
|
||||
char header_plus_data[200];
|
||||
strcpy (header_plus_data, header);
|
||||
strcat (header_plus_data, data);
|
||||
|
||||
FILE *test = fopen (new, "r");
|
||||
char buf[200];
|
||||
fflush (n);
|
||||
fread (buf, strlen (header_plus_data), 1, test);
|
||||
eputs ("buf=");
|
||||
eputs (buf);
|
||||
eputs ("\n");
|
||||
if (strcmp (buf, header_plus_data))
|
||||
return 1;
|
||||
|
||||
if (access (temp, R_OK))
|
||||
return 22;
|
||||
|
||||
unlink (temp);
|
||||
|
||||
if (!access (temp, R_OK))
|
||||
return 3;
|
||||
|
||||
unlink (new);
|
||||
|
||||
return 0;
|
||||
}
|
||||
61
sysa/mes-0.22/lib/tests/stdio/90-fseek.c
Normal file
61
sysa/mes-0.22/lib/tests/stdio/90-fseek.c
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/* -*-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 <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int fd = open ("../COPYING", O_RDONLY);
|
||||
if (fd <= 0)
|
||||
return 1;
|
||||
FILE *f = fdopen (fd, "r");
|
||||
int r = fseek (f, 0, SEEK_CUR);
|
||||
if (r != 0)
|
||||
return 2;
|
||||
int pos = ftell (f);
|
||||
if (pos != 0)
|
||||
return 3;
|
||||
|
||||
r = fseek (f, 0, SEEK_END);
|
||||
if (r != 0)
|
||||
return 4;
|
||||
|
||||
pos = ftell (f);
|
||||
eputs ("size=");
|
||||
eputs (itoa (pos));
|
||||
eputs ("\n");
|
||||
if (pos != 35147)
|
||||
return 5;
|
||||
r = fseek (f, 0, SEEK_SET);
|
||||
|
||||
char buf[4096];
|
||||
fgets (buf, 200, f);
|
||||
eputs ("buf:");
|
||||
eputs (buf);
|
||||
if (strcmp (buf, " GNU GENERAL PUBLIC LICENSE\n"))
|
||||
return 6;
|
||||
|
||||
return 0;
|
||||
}
|
||||
44
sysa/mes-0.22/lib/tests/stdio/90-sprintf.c
Normal file
44
sysa/mes-0.22/lib/tests/stdio/90-sprintf.c
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* -*-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>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
char buf[20];
|
||||
|
||||
int i = 0;
|
||||
printf ("%3.6d\n", i);
|
||||
sprintf (buf, "%3.6d", i);
|
||||
puts (buf);
|
||||
|
||||
double d = 1;
|
||||
printf ("%3.6f\n", d);
|
||||
sprintf (buf, "%3.6f", d);
|
||||
puts (buf);
|
||||
printf ("%3.6g\n", d);
|
||||
sprintf (buf, "%3.6g", d);
|
||||
puts (buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
6
sysa/mes-0.22/lib/tests/stdio/90-sprintf.stdout
Normal file
6
sysa/mes-0.22/lib/tests/stdio/90-sprintf.stdout
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
000000
|
||||
000000
|
||||
1.000000
|
||||
1.000000
|
||||
1
|
||||
1
|
||||
Loading…
Add table
Add a link
Reference in a new issue