projects
/
selector.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Set the file mode creation default to user only.
[selector.git]
/
selector.c
diff --git
a/selector.c
b/selector.c
index
26d97ae
..
0efdd1c
100644
(file)
--- a/
selector.c
+++ b/
selector.c
@@
-3,7
+3,7
@@
* selector is a simple command line utility for selection of strings
* with a dynamic pattern-matching.
*
* selector is a simple command line utility for selection of strings
* with a dynamic pattern-matching.
*
- * Copyright (c) 2009
, 2010, 2011, 2012
Francois Fleuret
+ * Copyright (c) 2009
-2013
Francois Fleuret
* Written by Francois Fleuret <francois@fleuret.org>
*
* This file is part of selector.
* Written by Francois Fleuret <francois@fleuret.org>
*
* This file is part of selector.
@@
-33,6
+33,7
@@
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
@@
-79,7
+80,7
@@
void *safe_malloc(size_t n) {
void *p = malloc(n);
if(!p && n != 0) {
fprintf(stderr,
void *p = malloc(n);
if(!p && n != 0) {
fprintf(stderr,
- "selector: can
not allocate memory: %s\n", strerror(errno));
+ "selector: cannot allocate memory: %s\n", strerror(errno));
exit(EXIT_FAILURE);
}
return p;
exit(EXIT_FAILURE);
}
return p;
@@
-339,7
+340,7
@@
int add_interval(int n, int *switches, int start, int end) {
while(g < n && switches[g] <= end) { g++; }
if(f == n) {
while(g < n && switches[g] <= end) { g++; }
if(f == n) {
- /* switches[
n
-1] start end */
+ /* switches[
f
-1] start end */
/* XXXXXXXXXXXX| */
switches[f] = start;
switches[f+1] = end;
/* XXXXXXXXXXXX| */
switches[f] = start;
switches[f+1] = end;
@@
-930,7
+931,7
@@
void read_file(struct hash_table_t *hash_table,
file = fopen(input_filename, "r");
if(!file) {
file = fopen(input_filename, "r");
if(!file) {
- fprintf(stderr, "selector: Can
not open `%s'.\n", input_filename);
+ fprintf(stderr, "selector: Cannot open `%s'.\n", input_filename);
exit(EXIT_FAILURE);
}
exit(EXIT_FAILURE);
}
@@
-1009,6
+1010,9
@@
int main(int argc, char **argv) {
struct hash_table_t *hash_table;
char *bash_histsize;
struct hash_table_t *hash_table;
char *bash_histsize;
+ /* Group and others have no access to created files */
+ umask(S_IRWXG | S_IRWXO);
+
if(!isatty(STDIN_FILENO)) {
fprintf(stderr, "selector: The standard input is not a tty.\n");
exit(EXIT_FAILURE);
if(!isatty(STDIN_FILENO)) {
fprintf(stderr, "selector: The standard input is not a tty.\n");
exit(EXIT_FAILURE);
@@
-1419,7
+1423,7
@@
int main(int argc, char **argv) {
fprintf(out, "\n");
} else {
fprintf(stderr,
fprintf(out, "\n");
} else {
fprintf(stderr,
- "selector: Can
not open %s for writing.\n",
+ "selector: Cannot open %s for writing.\n",
output_filename);
exit(EXIT_FAILURE);
}
output_filename);
exit(EXIT_FAILURE);
}