Name: Anonymous 2013-01-31 15:36
Write a program that displays "Hello world" (without quotes) to the screen.
/* /prog/ C Standard: 2013-01 <hello_world.h>, v0.1 */
/* Copyright (C) 2013 /prog/ libc Foundation, Inc.
This file is part of the /prog/ C Library.
The /prog/ C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The /prog/ C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the /prog/ C Library; if not, see
<http://www.gnu.org/licenses/>;.
*/
#ifndef PROG_HELLO_WORLD_H
#define PROG_HELLO_WORLD_H
/* Prints "Hello world" (without the quotes) on to the screen. /prog/ C standard
* 201301 defines quotes as harmful characters. The standard says that
* "Hello world" should be printed without quotes, and is ambigous in whether it
* should be in the source code or not. The standard does not define how the
* string is initialized, nor the presence of EOL after the string, nor it's
* return value. Returns 0 if "Hello world" is successfully printed,1 on
* failure.
*/
extern int hello_world(int, char **);
#endif
#if __PROGCSTD__ < 201301
#define hello_world(x, y) 0
#endif/* /prog/ C Standard: 2013-01 <hello_world.c>, v0.1 */
/* Copyright (C) 2013 /prog/ libc Foundation, Inc.
This file is part of the /prog/ C Library.
The /prog/ C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The /prog/ C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the /prog/ C Library; if not, see
<http://www.gnu.org/licenses/>;. */
#include <hello_world.h>
#include <stdio.h>
#include <string.h>
#undef safeprint
#undef safestrcmp
#undef hello_world
/* we use printf(3) and strcmp(3) which allow string literals to passed as
* arguments. These macros are temporary workarounds for when printf and strcmp
* become /prog/ C standard compilant.
*/
#define safeprintf(x, ...) printf(#x, __VA_ARGS__)
#define safestrcmp(x, y) strcmp(#x, y)
int hello_world(int n, char **src) {
/* This eliminates all quotes */
if(n == 3) {
/* we only want to print "Hello world" */
if(safestrcmp(Hello, src[1]) == 0
&& safestrcmp(world, src[2]) == 0)
if(safeprintf(%s %s, src[1], src[2]) < 0) return 1;
else return 1;
}
else return 1;
putchar(10);
return 0;
}
#include <hello_world.h>
int main(int argc, char **argv) {
return hello_world(argc, argv);
}
--- hello_world.c.orig 2013-02-02 03:18:40.534394992 +0500
+++ hello_world.c 2013-02-02 03:15:34.768675391 +0500
@@ -37,6 +37,7 @@
if(safestrcmp(Hello, src[1]) == 0
&& safestrcmp(world, src[2]) == 0)
if(safeprintf(%s %s, src[1], src[2]) < 0) return 1;
+ else ;
else return 1;
}
else return 1;