1
0

xor instead of more complicated version from a text editor tutorial

This commit is contained in:
dtb 2023-12-09 10:01:49 -07:00
parent 81cc1ef31b
commit 02353836ca

View File

@ -17,7 +17,7 @@ int main(int argc, char *argv[]){
/* disable terminal echo */
tcgetattr(STDIN_FILENO, &t);
t.c_lflag &= ~(ECHO);
t.c_lflag ^= ECHO;
tcsetattr(STDIN_FILENO, TCSAFLUSH, &t);
eof = EOF;
@ -30,6 +30,7 @@ int main(int argc, char *argv[]){
case 'e': to_stderr = 1; break;
case 'n': include_eof = 1; break;
case 'o': to_stdout = 1; break;
case 'p': printf("not yet implemented\n");
default:
fprintf(stderr, "Usage: %s (-1eno) (-p [program])\n",
argv[0] == NULL ? program_name : argv[0]);
@ -49,5 +50,9 @@ int main(int argc, char *argv[]){
if(include_eof && to_stderr)
putc(c, stderr);
tcgetattr(STDIN_FILENO, &t);
t.c_lflag |= ECHO;
tcsetattr(STDIN_FILENO, TCSAFLUSH, &t);
return EX_OK;
}