Browse Source

don't output newline if output is not going to terminal

master
Felix von Leitner 17 years ago
parent
commit
bc4c322160
  1. 8
      test/b64decode.c
  2. 6
      test/b64encode.c

8
test/b64decode.c

@ -1,11 +1,12 @@
#include <string.h>
#include <unistd.h>
#include "buffer.h"
#include "textcode.h"
#include "havealloca.h"
void b64encode(const char* c) {
char* buf=alloca(strlen(c)*2+4);
unsigned int dlen;
unsigned long dlen;
scan_base64(c,buf,&dlen);
buffer_put(buffer_1,buf,dlen);
}
@ -23,7 +24,10 @@ main(int argc,char* argv[]) {
src[len]=0;
b64encode(src);
}
buffer_putnlflush(buffer_1);
if (isatty(1))
buffer_putnlflush(buffer_1);
else
buffer_flush(buffer_1);
if (len==-1) return(1);
}
return 0;

6
test/b64encode.c

@ -1,3 +1,4 @@
#include <unistd.h>
#include <string.h>
#include "buffer.h"
#include "textcode.h"
@ -6,7 +7,10 @@
void b64encode(const char* c) {
char* buf=alloca(strlen(c)*2+4);
buffer_put(buffer_1,buf,fmt_base64(buf,c,strlen(c)));
buffer_putnlflush(buffer_1);
if (isatty(1))
buffer_putnlflush(buffer_1);
else
buffer_flush(buffer_1);
}
main(int argc,char* argv[]) {

Loading…
Cancel
Save