mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 03:08:31 +00:00
Add glob and some finer tuning of documentation
This commit is contained in:
parent
799e24a87b
commit
d51409ccd9
77 changed files with 1321 additions and 736 deletions
31
tool/build/summy.c
Normal file
31
tool/build/summy.c
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
||||
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ This program is free software; you can redistribute it and/or modify │
|
||||
│ it under the terms of the GNU General Public License as published by │
|
||||
│ the Free Software Foundation; version 2 of the License. │
|
||||
│ │
|
||||
│ This program is distributed in the hope that it will be useful, but │
|
||||
│ WITHOUT ANY WARRANTY; without even the implied warranty of │
|
||||
│ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU │
|
||||
│ General Public License for more details. │
|
||||
│ │
|
||||
│ You should have received a copy of the GNU General Public License │
|
||||
│ along with this program; if not, write to the Free Software │
|
||||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/stdio/stdio.h"
|
||||
|
||||
/**
|
||||
* @fileoverview Sums per-line integers from stdin.
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
long x, sum = 0;
|
||||
while (scanf("%ld", &x) > 0) sum += x;
|
||||
printf("%,ld\n", sum);
|
||||
return 0;
|
||||
}
|
|
@ -62,6 +62,7 @@
|
|||
|
||||
char *symbol_;
|
||||
char *outpath_;
|
||||
char *yoink_;
|
||||
|
||||
const size_t kMinCompressSize = 32;
|
||||
const char kNoCompressExts[][8] = {".gz", ".xz", ".jpg", ".png",
|
||||
|
@ -70,13 +71,14 @@ const char kNoCompressExts[][8] = {".gz", ".xz", ".jpg", ".png",
|
|||
|
||||
noreturn void PrintUsage(int rc, FILE *f) {
|
||||
fprintf(f, "%s%s%s\n", "Usage: ", program_invocation_name,
|
||||
" [-o FILE] [-s SYMBOL] [FILE...]\n");
|
||||
" [-o FILE] [-s SYMBOL] [-y YOINK] [FILE...]\n");
|
||||
exit(rc);
|
||||
}
|
||||
|
||||
void GetOpts(int *argc, char ***argv) {
|
||||
int opt;
|
||||
while ((opt = getopt(*argc, *argv, "?ho:s:")) != -1) {
|
||||
yoink_ = "__zip_start";
|
||||
while ((opt = getopt(*argc, *argv, "?ho:s:y:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'o':
|
||||
outpath_ = optarg;
|
||||
|
@ -84,6 +86,9 @@ void GetOpts(int *argc, char ***argv) {
|
|||
case 's':
|
||||
symbol_ = optarg;
|
||||
break;
|
||||
case 'y':
|
||||
yoink_ = optarg;
|
||||
break;
|
||||
case '?':
|
||||
case 'h':
|
||||
PrintUsage(EXIT_SUCCESS, stdout);
|
||||
|
@ -273,8 +278,7 @@ void PullEndOfCentralDirectoryIntoLinkage(struct ElfWriter *elf) {
|
|||
elfwriter_align(elf, 1, 0);
|
||||
elfwriter_startsection(elf, ".yoink", SHT_PROGBITS,
|
||||
SHF_ALLOC | SHF_EXECINSTR);
|
||||
elfwriter_yoink(elf, "__zip_start");
|
||||
elfwriter_yoink(elf, "__zip_end");
|
||||
elfwriter_yoink(elf, yoink_);
|
||||
elfwriter_finishsection(elf);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue