Merge pull request #2392 from colinleroy/asm-fputc-fputs

Asm fputc fputs
This commit is contained in:
Bob Andrews
2024-02-02 19:41:23 +01:00
committed by GitHub
9 changed files with 210 additions and 81 deletions

39
test/ref/test_fputc.c Normal file
View File

@@ -0,0 +1,39 @@
/*
!!DESCRIPTION!! fgets test
!!LICENCE!! Public domain
*/
#include "common.h"
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
FILE *in, *out;
int c, err;
#define INFILE "cf.in"
int main(int argc,char **argv)
{
in = fopen(INFILE, "rb");
if (in == NULL) {
return EXIT_FAILURE;
}
if (fputc(c, in) != EOF) {
printf("Error: can fputc to a file opened for reading\n");
return EXIT_FAILURE;
}
clearerr(in);
while ((c = fgetc(in)) != EOF) {
fputc(c, stdout);
}
fclose(in);
return 0;
}

40
test/ref/test_fputs.c Normal file
View File

@@ -0,0 +1,40 @@
/*
!!DESCRIPTION!! fgets test
!!LICENCE!! Public domain
*/
#include "common.h"
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
FILE *in, *out;
char buf[512], err;
#define INFILE "cf.in"
int main(int argc,char **argv)
{
in = fopen(INFILE, "rb");
if (in == NULL) {
return EXIT_FAILURE;
}
strcpy(buf, "test");
if (fputs(buf, in) != EOF) {
printf("Error: can fputs to a file opened for reading\n");
return EXIT_FAILURE;
}
clearerr(in);
while (fgets(buf, 512, in) != NULL) {
fputs(buf, stdout);
}
fclose(in);
return 0;
}