uppercase(1)
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
all: lowercase
|
||||
all: lowercase uppercase
|
||||
clean:
|
||||
rm -f lowercase
|
||||
sane: lowercase
|
||||
rm -f lowercase uppercase
|
||||
sane: all
|
||||
|
||||
lowercase: ../ascii/ascii.h lowercase.c
|
||||
$(CC) -I../ascii/ -o lowercase lowercase.c
|
||||
lowercase: lowercase.c
|
||||
$(CC) -DLOWERCASE -o lowercase lowercase.c
|
||||
|
||||
uppercase: lowercase.c
|
||||
$(CC) -DUPPERCASE -o uppercase lowercase.c
|
||||
|
||||
.PHONY: all clean sane
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#include <ascii.h> /* ASCII_MAX_VALUE */
|
||||
#include <stdio.h> /* fprintf(3), getc(3), putc(3), stderr, stdin, stdout */
|
||||
#include <stdlib.h> /* exit(3) */
|
||||
#include <sysexits.h> /* EX_OK, EX_USAGE, EX_SOFTWARE */
|
||||
@@ -6,13 +5,16 @@
|
||||
|
||||
/* Enable Unicode support using official Unicode library. */
|
||||
#ifdef USE_ICU
|
||||
# include <unicode/uchar.h> /* UCHAR_MAX_VALUE, u_tolower(3) */
|
||||
# include <unicode/uchar.h>
|
||||
/* UCHAR_MAX_VALUE, u_tolower(3), u_toupper(3) */
|
||||
# include <unicode/umachine.h> /* UChar32 */
|
||||
# include <unicode/ustdio.h> /* u_fgetc(3) */
|
||||
#else
|
||||
# include <ctype.h> /* tolower(3) */
|
||||
# include <ctype.h> /* tolower(3), toupper(3) */
|
||||
#endif /* USE_ICU */
|
||||
|
||||
#define ASCII_MAX_VALUE 0x7F
|
||||
|
||||
int main(int argc, char *argv[]){
|
||||
#ifdef USE_ICU
|
||||
UChar32
|
||||
@@ -30,14 +32,22 @@ int main(int argc, char *argv[]){
|
||||
#ifdef USE_ICU
|
||||
while((c = u_fgetc(stdin)) != U_EOF){
|
||||
if(c <= UCHAR_MAX_VALUE && c >= 0)
|
||||
# ifdef LOWERCASE
|
||||
c = u_tolower(c);
|
||||
# else
|
||||
c = u_toupper(c);
|
||||
# endif /* ifdef LOWERCASE */
|
||||
u_fputc(c, stdout);
|
||||
#else
|
||||
while((c = getc(stdin)) != EOF){
|
||||
if(c <= ASCII_MAX_VALUE && c >= 0)
|
||||
# ifdef LOWERCASE
|
||||
c = tolower(c);
|
||||
# else
|
||||
c = toupper(c);
|
||||
# endif /* ifdef LOWERCASE */
|
||||
putc(c, stdout);
|
||||
#endif
|
||||
#endif /* ifdef USE_ICU */
|
||||
}
|
||||
return EX_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user