| 1 |
#include <stdio.h>
|
| 2 |
#include <locale.h>
|
| 3 |
#include <stdlib.h>
|
| 4 |
#include <string.h>
|
| 5 |
#include <wchar.h>
|
| 6 |
|
| 7 |
int
|
| 8 |
main(int argc, char **argv)
|
| 9 |
{
|
| 10 |
int space;
|
| 11 |
int length;
|
| 12 |
int width;
|
| 13 |
wchar_t *string;
|
| 14 |
setlocale(LC_ALL, "");
|
| 15 |
sscanf(argv[1], "%i", &space);
|
| 16 |
length = strlen(argv[2]);
|
| 17 |
string = (wchar_t *) malloc(sizeof(wchar_t[length]));
|
| 18 |
mbstowcs(string, argv[2], length + 2);
|
| 19 |
width = wcswidth(string, length + 2);
|
| 20 |
if (space > 0 && space > width) {
|
| 21 |
int i;
|
| 22 |
for (i = width; i < space; i++)
|
| 23 |
putchar(' ');
|
| 24 |
}
|
| 25 |
printf("%s", argv[2]);
|
| 26 |
if (space < 0 && -space > width) {
|
| 27 |
int i;
|
| 28 |
for (i = width; i < -space; i++)
|
| 29 |
putchar(' ');
|
| 30 |
}
|
| 31 |
return 0;
|
| 32 |
}
|
| 33 |
|
| 34 |
|
| 35 |
/*
|
| 36 |
Local variables:
|
| 37 |
indent-tabs-mode: nil
|
| 38 |
c-file-style: "linux"
|
| 39 |
c-font-lock-extra-types: ("FILE" "\\sw+_t" "bool" "Ped\\sw+")
|
| 40 |
End:
|
| 41 |
*/
|