History

add * to list the keys of a dict

Sigrid Solveig Haflínudóttir committed 5 years ago

Commit 77b04081 parent a04da7c1 file · +6 −1Browse files

Unified · Split

main.c+6−1
@@ -22,7 +22,7 @@ threadmain(int argc, char **argv) · 21 unmodified lines
2222 Biobuf *b;
2323 Stream *s;
2424 Pdf *pdf;
25− int i, n;
25+ int i, n, k;
2626
2727 quotefmtinstall();
2828 inflateinit();
@@ -50,6 +50,11 @@ threadmain(int argc, char **argv) · 21 unmodified lines
5050 Sclose(s);
5151 v = nil;
5252 break;
53+ }else if(argv[i][0] == '*' && argv[i][1] == 0 && v->type == Odict){
54+ for(k = 0; k < v->dict.nkv; k++)
55+ print("%s\n", v->dict.kv[k].key);
56+ v = nil;
57+ break;
5358 }else if(argv[i][0] == '@' && argv[i][1] == 0 && v->type == Ostream){
5459 fprint(2, "%d %d\n", v->stream.off, v->stream.len);
5560 v = nil;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t