summaryrefslogtreecommitdiff
path: root/sys/src/cmd/file.c
diff options
context:
space:
mode:
authorAlex Musolino <alex@musolino.id.au>2019-06-08 15:56:03 +0930
committerAlex Musolino <alex@musolino.id.au>2019-06-08 15:56:03 +0930
commit26dc73c763de25196a60caba7f7815b13cf2f91f (patch)
treed4e5878f6562307fee8fb6fe25a987d57d707e1c /sys/src/cmd/file.c
parent78c7cd0c010c1c90dbc3358c2710bddaed379ce9 (diff)
file(1): recognise unified diff output
Diffstat (limited to 'sys/src/cmd/file.c')
-rw-r--r--sys/src/cmd/file.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/src/cmd/file.c b/sys/src/cmd/file.c
index b64bb13a4..854e8e07c 100644
--- a/sys/src/cmd/file.c
+++ b/sys/src/cmd/file.c
@@ -167,6 +167,7 @@ int longoff(void);
int istar(void);
int isface(void);
int isexec(void);
+int isudiff(void);
int p9bitnum(char*, int*);
int p9subfont(uchar*);
void print_utf(void);
@@ -183,6 +184,7 @@ int (*call[])(void) =
iff, /* interchange file format (strings) */
longoff, /* recognizable by 4 bytes at some offset */
isoffstr, /* recognizable by string at some offset */
+ isudiff, /* unified diff output */
isrfc822, /* email file */
ismbox, /* mail box */
istar, /* recognizable by tar checksum */
@@ -983,6 +985,25 @@ char* html_string[] = {
};
int
+isudiff(void)
+{
+ char *p;
+
+ p = (char*)buf;
+ if((p = strstr(p, "diff")) != nil)
+ if((p = strchr(p, '\n')) != nil)
+ if(strncmp(++p, "--- ", 4) == 0)
+ if((p = strchr(p, '\n')) != nil)
+ if(strncmp(++p, "+++ ", 4) == 0)
+ if((p = strchr(p, '\n')) != nil)
+ if(strncmp(++p, "@@ ", 3) == 0){
+ print("%s\n", mime ? "text/plain" : "unified diff output");
+ return 1;
+ }
+ return 0;
+}
+
+int
ishtml(void)
{
int i, n, count;