Index: vendor/OpenBSD/dist/usr.bin/rcs/ident.c =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/ident.c (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/ident.c (nonexistent) @@ -1,169 +0,0 @@ -/* $OpenBSD: ident.c,v 1.30 2014/10/02 06:23:15 otto Exp $ */ -/* - * Copyright (c) 2005 Xavier Santolaria - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "rcsprog.h" - -#define KEYDELIM '$' /* keywords delimiter */ -#define VALDELIM ':' /* values delimiter */ - -static int found = 0; -static int flags = 0; - -static void ident_file(const char *, FILE *); -static void ident_line(FILE *); - -int -ident_main(int argc, char **argv) -{ - int i, ch, status; - FILE *fp; - - status = 0; - - while ((ch = rcs_getopt(argc, argv, "qV")) != -1) { - switch(ch) { - case 'q': - flags |= QUIET; - break; - case 'V': - printf("%s\n", rcs_version); - exit(0); - default: - (usage)(); - } - } - - argc -= rcs_optind; - argv += rcs_optind; - - if (argc == 0) - ident_file(NULL, stdin); - else { - for (i = 0; i < argc; i++) { - if ((fp = fopen(argv[i], "r")) == NULL) { - warn("%s", argv[i]); - status = 1; - continue; - } - - ident_file(argv[i], fp); - (void)fclose(fp); - if (i != argc - 1) - printf("\n"); - } - } - - return (status); -} - - -static void -ident_file(const char *filename, FILE *fp) -{ - int c; - - if (filename != NULL) - printf("%s:\n", filename); - else - filename = "standard input"; - - for (c = 0; c != EOF; c = getc(fp)) { - if (feof(fp) || ferror(fp)) - break; - if (c == KEYDELIM) - ident_line(fp); - } - - if (found == 0 && !(flags & QUIET)) - fprintf(stderr, "ident warning: no id keywords in %s\n", - filename); - - found = 0; -} - -static void -ident_line(FILE *fp) -{ - int c; - BUF *bp; - size_t len; - - bp = buf_alloc(512); - - while ((c = getc(fp)) != VALDELIM) { - if (c == EOF) - goto out; - - if (isalpha(c)) - buf_putc(bp, c); - else - goto out; - } - - buf_putc(bp, VALDELIM); - - while ((c = getc(fp)) != KEYDELIM) { - if (c == EOF) - goto out; - - if (c == '\n') - goto out; - - buf_putc(bp, c); - } - - len = buf_len(bp); - if (buf_getc(bp, len - 1) != ' ') - goto out; - - /* append trailing KEYDELIM */ - buf_putc(bp, c); - - /* Append newline for printing. */ - buf_putc(bp, '\n'); - printf(" %c", KEYDELIM); - fflush(stdout); - buf_write_fd(bp, STDOUT_FILENO); - - found++; -out: - if (bp != NULL) - buf_free(bp); -} - -__dead void -ident_usage(void) -{ - fprintf(stderr, "usage: ident [-qV] [file ...]\n"); - - exit(1); -} Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/ident.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/date.y =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/date.y (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/date.y (nonexistent) @@ -1,894 +0,0 @@ -%{ -/* $OpenBSD: date.y,v 1.12 2013/12/03 00:21:49 deraadt Exp $ */ - -/* -** Originally written by Steven M. Bellovin while -** at the University of North Carolina at Chapel Hill. Later tweaked by -** a couple of people on Usenet. Completely overhauled by Rich $alz -** and Jim Berets in August, 1990; -** -** This grammar has 10 shift/reduce conflicts. -** -** This code is in the public domain and has no copyright. -*/ -/* SUPPRESS 287 on yaccpar_sccsid *//* Unused static variable */ -/* SUPPRESS 288 on yyerrlab *//* Label unused */ - -#include -#include -#include - -#include "rcsprog.h" - -#define YEAR_EPOCH 1970 -#define YEAR_TMORIGIN 1900 -#define HOUR(x) ((time_t)(x) * 60) -#define SECSPERDAY (24L * 60L * 60L) - - -/* An entry in the lexical lookup table */ -typedef struct _TABLE { - char *name; - int type; - time_t value; -} TABLE; - - -/* Daylight-savings mode: on, off, or not yet known. */ -typedef enum _DSTMODE { - DSTon, DSToff, DSTmaybe -} DSTMODE; - -/* Meridian: am, pm, or 24-hour style. */ -typedef enum _MERIDIAN { - MERam, MERpm, MER24 -} MERIDIAN; - - -/* - * Global variables. We could get rid of most of these by using a good - * union as the yacc stack. (This routine was originally written before - * yacc had the %union construct.) Maybe someday; right now we only use - * the %union very rarely. - */ -static const char *yyInput; -static DSTMODE yyDSTmode; -static time_t yyDayOrdinal; -static time_t yyDayNumber; -static int yyHaveDate; -static int yyHaveDay; -static int yyHaveRel; -static int yyHaveTime; -static int yyHaveZone; -static time_t yyTimezone; -static time_t yyDay; -static time_t yyHour; -static time_t yyMinutes; -static time_t yyMonth; -static time_t yySeconds; -static time_t yyYear; -static MERIDIAN yyMeridian; -static time_t yyRelMonth; -static time_t yyRelSeconds; - - -static int yyerror(const char *); -static int yylex(void); -static int yyparse(void); -static int lookup(char *); - -%} - -%union { - time_t Number; - enum _MERIDIAN Meridian; -} - -%token tAGO tDAY tDAYZONE tID tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT -%token tSEC_UNIT tSNUMBER tUNUMBER tZONE tDST - -%type tDAY tDAYZONE tMINUTE_UNIT tMONTH tMONTH_UNIT -%type tSEC_UNIT tSNUMBER tUNUMBER tZONE -%type tMERIDIAN o_merid - -%% - -spec : /* NULL */ - | spec item - ; - -item : time { - yyHaveTime++; - } - | zone { - yyHaveZone++; - } - | date { - yyHaveDate++; - } - | day { - yyHaveDay++; - } - | rel { - yyHaveRel++; - } - | number - ; - -time : tUNUMBER tMERIDIAN { - yyHour = $1; - yyMinutes = 0; - yySeconds = 0; - yyMeridian = $2; - } - | tUNUMBER ':' tUNUMBER o_merid { - yyHour = $1; - yyMinutes = $3; - yySeconds = 0; - yyMeridian = $4; - } - | tUNUMBER ':' tUNUMBER tSNUMBER { - yyHour = $1; - yyMinutes = $3; - yyMeridian = MER24; - yyDSTmode = DSToff; - yyTimezone = - ($4 % 100 + ($4 / 100) * 60); - } - | tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid { - yyHour = $1; - yyMinutes = $3; - yySeconds = $5; - yyMeridian = $6; - } - | tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER { - yyHour = $1; - yyMinutes = $3; - yySeconds = $5; - yyMeridian = MER24; - yyDSTmode = DSToff; - yyTimezone = - ($6 % 100 + ($6 / 100) * 60); - } - ; - -zone : tZONE { - yyTimezone = $1; - yyDSTmode = DSToff; - } - | tDAYZONE { - yyTimezone = $1; - yyDSTmode = DSTon; - } - | tZONE tDST { - yyTimezone = $1; - yyDSTmode = DSTon; - } - ; - -day : tDAY { - yyDayOrdinal = 1; - yyDayNumber = $1; - } - | tDAY ',' { - yyDayOrdinal = 1; - yyDayNumber = $1; - } - | tUNUMBER tDAY { - yyDayOrdinal = $1; - yyDayNumber = $2; - } - ; - -date : tUNUMBER '/' tUNUMBER { - yyMonth = $1; - yyDay = $3; - } - | tUNUMBER '/' tUNUMBER '/' tUNUMBER { - if ($1 >= 100) { - yyYear = $1; - yyMonth = $3; - yyDay = $5; - } else { - yyMonth = $1; - yyDay = $3; - yyYear = $5; - } - } - | tUNUMBER tSNUMBER tSNUMBER { - /* ISO 8601 format. yyyy-mm-dd. */ - yyYear = $1; - yyMonth = -$2; - yyDay = -$3; - } - | tUNUMBER tMONTH tSNUMBER { - /* e.g. 17-JUN-1992. */ - yyDay = $1; - yyMonth = $2; - yyYear = -$3; - } - | tMONTH tUNUMBER { - yyMonth = $1; - yyDay = $2; - } - | tMONTH tUNUMBER ',' tUNUMBER { - yyMonth = $1; - yyDay = $2; - yyYear = $4; - } - | tUNUMBER tMONTH { - yyMonth = $2; - yyDay = $1; - } - | tUNUMBER tMONTH tUNUMBER { - yyMonth = $2; - yyDay = $1; - yyYear = $3; - } - ; - -rel : relunit tAGO { - yyRelSeconds = -yyRelSeconds; - yyRelMonth = -yyRelMonth; - } - | relunit - ; - -relunit : tUNUMBER tMINUTE_UNIT { - yyRelSeconds += $1 * $2 * 60L; - } - | tSNUMBER tMINUTE_UNIT { - yyRelSeconds += $1 * $2 * 60L; - } - | tMINUTE_UNIT { - yyRelSeconds += $1 * 60L; - } - | tSNUMBER tSEC_UNIT { - yyRelSeconds += $1; - } - | tUNUMBER tSEC_UNIT { - yyRelSeconds += $1; - } - | tSEC_UNIT { - yyRelSeconds++; - } - | tSNUMBER tMONTH_UNIT { - yyRelMonth += $1 * $2; - } - | tUNUMBER tMONTH_UNIT { - yyRelMonth += $1 * $2; - } - | tMONTH_UNIT { - yyRelMonth += $1; - } - ; - -number : tUNUMBER { - if (yyHaveTime && yyHaveDate && !yyHaveRel) - yyYear = $1; - else { - if ($1 > 10000) { - yyHaveDate++; - yyDay= ($1)%100; - yyMonth= ($1/100)%100; - yyYear = $1/10000; - } else { - yyHaveTime++; - if ($1 < 100) { - yyHour = $1; - yyMinutes = 0; - } else { - yyHour = $1 / 100; - yyMinutes = $1 % 100; - } - yySeconds = 0; - yyMeridian = MER24; - } - } - } - ; - -o_merid : /* NULL */ { - $$ = MER24; - } - | tMERIDIAN { - $$ = $1; - } - ; - -%% - -/* Month and day table. */ -static TABLE const MonthDayTable[] = { - { "january", tMONTH, 1 }, - { "february", tMONTH, 2 }, - { "march", tMONTH, 3 }, - { "april", tMONTH, 4 }, - { "may", tMONTH, 5 }, - { "june", tMONTH, 6 }, - { "july", tMONTH, 7 }, - { "august", tMONTH, 8 }, - { "september", tMONTH, 9 }, - { "sept", tMONTH, 9 }, - { "october", tMONTH, 10 }, - { "november", tMONTH, 11 }, - { "december", tMONTH, 12 }, - { "sunday", tDAY, 0 }, - { "monday", tDAY, 1 }, - { "tuesday", tDAY, 2 }, - { "tues", tDAY, 2 }, - { "wednesday", tDAY, 3 }, - { "wednes", tDAY, 3 }, - { "thursday", tDAY, 4 }, - { "thur", tDAY, 4 }, - { "thurs", tDAY, 4 }, - { "friday", tDAY, 5 }, - { "saturday", tDAY, 6 }, - { NULL } -}; - -/* Time units table. */ -static TABLE const UnitsTable[] = { - { "year", tMONTH_UNIT, 12 }, - { "month", tMONTH_UNIT, 1 }, - { "fortnight", tMINUTE_UNIT, 14 * 24 * 60 }, - { "week", tMINUTE_UNIT, 7 * 24 * 60 }, - { "day", tMINUTE_UNIT, 1 * 24 * 60 }, - { "hour", tMINUTE_UNIT, 60 }, - { "minute", tMINUTE_UNIT, 1 }, - { "min", tMINUTE_UNIT, 1 }, - { "second", tSEC_UNIT, 1 }, - { "sec", tSEC_UNIT, 1 }, - { NULL } -}; - -/* Assorted relative-time words. */ -static TABLE const OtherTable[] = { - { "tomorrow", tMINUTE_UNIT, 1 * 24 * 60 }, - { "yesterday", tMINUTE_UNIT, -1 * 24 * 60 }, - { "today", tMINUTE_UNIT, 0 }, - { "now", tMINUTE_UNIT, 0 }, - { "last", tUNUMBER, -1 }, - { "this", tMINUTE_UNIT, 0 }, - { "next", tUNUMBER, 2 }, - { "first", tUNUMBER, 1 }, -/* { "second", tUNUMBER, 2 }, */ - { "third", tUNUMBER, 3 }, - { "fourth", tUNUMBER, 4 }, - { "fifth", tUNUMBER, 5 }, - { "sixth", tUNUMBER, 6 }, - { "seventh", tUNUMBER, 7 }, - { "eighth", tUNUMBER, 8 }, - { "ninth", tUNUMBER, 9 }, - { "tenth", tUNUMBER, 10 }, - { "eleventh", tUNUMBER, 11 }, - { "twelfth", tUNUMBER, 12 }, - { "ago", tAGO, 1 }, - { NULL } -}; - -/* The timezone table. */ -/* Some of these are commented out because a time_t can't store a float. */ -static TABLE const TimezoneTable[] = { - { "gmt", tZONE, HOUR( 0) }, /* Greenwich Mean */ - { "ut", tZONE, HOUR( 0) }, /* Universal (Coordinated) */ - { "utc", tZONE, HOUR( 0) }, - { "wet", tZONE, HOUR( 0) }, /* Western European */ - { "bst", tDAYZONE, HOUR( 0) }, /* British Summer */ - { "wat", tZONE, HOUR( 1) }, /* West Africa */ - { "at", tZONE, HOUR( 2) }, /* Azores */ -#if 0 - /* For completeness. BST is also British Summer, and GST is - * also Guam Standard. */ - { "bst", tZONE, HOUR( 3) }, /* Brazil Standard */ - { "gst", tZONE, HOUR( 3) }, /* Greenland Standard */ -#endif -#if 0 - { "nft", tZONE, HOUR(3.5) }, /* Newfoundland */ - { "nst", tZONE, HOUR(3.5) }, /* Newfoundland Standard */ - { "ndt", tDAYZONE, HOUR(3.5) }, /* Newfoundland Daylight */ -#endif - { "ast", tZONE, HOUR( 4) }, /* Atlantic Standard */ - { "adt", tDAYZONE, HOUR( 4) }, /* Atlantic Daylight */ - { "est", tZONE, HOUR( 5) }, /* Eastern Standard */ - { "edt", tDAYZONE, HOUR( 5) }, /* Eastern Daylight */ - { "cst", tZONE, HOUR( 6) }, /* Central Standard */ - { "cdt", tDAYZONE, HOUR( 6) }, /* Central Daylight */ - { "mst", tZONE, HOUR( 7) }, /* Mountain Standard */ - { "mdt", tDAYZONE, HOUR( 7) }, /* Mountain Daylight */ - { "pst", tZONE, HOUR( 8) }, /* Pacific Standard */ - { "pdt", tDAYZONE, HOUR( 8) }, /* Pacific Daylight */ - { "yst", tZONE, HOUR( 9) }, /* Yukon Standard */ - { "ydt", tDAYZONE, HOUR( 9) }, /* Yukon Daylight */ - { "hst", tZONE, HOUR(10) }, /* Hawaii Standard */ - { "hdt", tDAYZONE, HOUR(10) }, /* Hawaii Daylight */ - { "cat", tZONE, HOUR(10) }, /* Central Alaska */ - { "ahst", tZONE, HOUR(10) }, /* Alaska-Hawaii Standard */ - { "nt", tZONE, HOUR(11) }, /* Nome */ - { "idlw", tZONE, HOUR(12) }, /* International Date Line West */ - { "cet", tZONE, -HOUR(1) }, /* Central European */ - { "met", tZONE, -HOUR(1) }, /* Middle European */ - { "mewt", tZONE, -HOUR(1) }, /* Middle European Winter */ - { "mest", tDAYZONE, -HOUR(1) }, /* Middle European Summer */ - { "swt", tZONE, -HOUR(1) }, /* Swedish Winter */ - { "sst", tDAYZONE, -HOUR(1) }, /* Swedish Summer */ - { "fwt", tZONE, -HOUR(1) }, /* French Winter */ - { "fst", tDAYZONE, -HOUR(1) }, /* French Summer */ - { "eet", tZONE, -HOUR(2) }, /* Eastern Europe, USSR Zone 1 */ - { "bt", tZONE, -HOUR(3) }, /* Baghdad, USSR Zone 2 */ -#if 0 - { "it", tZONE, -HOUR(3.5) },/* Iran */ -#endif - { "zp4", tZONE, -HOUR(4) }, /* USSR Zone 3 */ - { "zp5", tZONE, -HOUR(5) }, /* USSR Zone 4 */ -#if 0 - { "ist", tZONE, -HOUR(5.5) },/* Indian Standard */ -#endif - { "zp6", tZONE, -HOUR(6) }, /* USSR Zone 5 */ -#if 0 - /* For completeness. NST is also Newfoundland Stanard, and SST is - * also Swedish Summer. */ - { "nst", tZONE, -HOUR(6.5) },/* North Sumatra */ - { "sst", tZONE, -HOUR(7) }, /* South Sumatra, USSR Zone 6 */ -#endif /* 0 */ - { "wast", tZONE, -HOUR(7) }, /* West Australian Standard */ - { "wadt", tDAYZONE, -HOUR(7) }, /* West Australian Daylight */ -#if 0 - { "jt", tZONE, -HOUR(7.5) },/* Java (3pm in Cronusland!) */ -#endif - { "cct", tZONE, -HOUR(8) }, /* China Coast, USSR Zone 7 */ - { "jst", tZONE, -HOUR(9) }, /* Japan Standard, USSR Zone 8 */ -#if 0 - { "cast", tZONE, -HOUR(9.5) },/* Central Australian Standard */ - { "cadt", tDAYZONE, -HOUR(9.5) },/* Central Australian Daylight */ -#endif - { "east", tZONE, -HOUR(10) }, /* Eastern Australian Standard */ - { "eadt", tDAYZONE, -HOUR(10) }, /* Eastern Australian Daylight */ - { "gst", tZONE, -HOUR(10) }, /* Guam Standard, USSR Zone 9 */ - { "nzt", tZONE, -HOUR(12) }, /* New Zealand */ - { "nzst", tZONE, -HOUR(12) }, /* New Zealand Standard */ - { "nzdt", tDAYZONE, -HOUR(12) }, /* New Zealand Daylight */ - { "idle", tZONE, -HOUR(12) }, /* International Date Line East */ - { NULL } -}; - -/* Military timezone table. */ -static TABLE const MilitaryTable[] = { - { "a", tZONE, HOUR( 1) }, - { "b", tZONE, HOUR( 2) }, - { "c", tZONE, HOUR( 3) }, - { "d", tZONE, HOUR( 4) }, - { "e", tZONE, HOUR( 5) }, - { "f", tZONE, HOUR( 6) }, - { "g", tZONE, HOUR( 7) }, - { "h", tZONE, HOUR( 8) }, - { "i", tZONE, HOUR( 9) }, - { "k", tZONE, HOUR( 10) }, - { "l", tZONE, HOUR( 11) }, - { "m", tZONE, HOUR( 12) }, - { "n", tZONE, HOUR(- 1) }, - { "o", tZONE, HOUR(- 2) }, - { "p", tZONE, HOUR(- 3) }, - { "q", tZONE, HOUR(- 4) }, - { "r", tZONE, HOUR(- 5) }, - { "s", tZONE, HOUR(- 6) }, - { "t", tZONE, HOUR(- 7) }, - { "u", tZONE, HOUR(- 8) }, - { "v", tZONE, HOUR(- 9) }, - { "w", tZONE, HOUR(-10) }, - { "x", tZONE, HOUR(-11) }, - { "y", tZONE, HOUR(-12) }, - { "z", tZONE, HOUR( 0) }, - { NULL } -}; - - -static int -yyerror(const char *s) -{ - char *str; - - if (isspace(yyInput[0]) || !isprint(yyInput[0])) - (void)xasprintf(&str, - "%s: unexpected char 0x%02x in date string", s, yyInput[0]); - else - (void)xasprintf(&str, "%s: unexpected %s in date string", - s, yyInput); - - warnx("%s", str); - xfree(str); - return (0); -} - - -static time_t -ToSeconds(time_t Hours, time_t Minutes, time_t Seconds, MERIDIAN Meridian) -{ - if (Minutes < 0 || Minutes > 59 || Seconds < 0 || Seconds > 59) - return (-1); - - switch (Meridian) { - case MER24: - if (Hours < 0 || Hours > 23) - return (-1); - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERam: - if (Hours < 1 || Hours > 12) - return (-1); - if (Hours == 12) - Hours = 0; - return (Hours * 60L + Minutes) * 60L + Seconds; - case MERpm: - if (Hours < 1 || Hours > 12) - return (-1); - if (Hours == 12) - Hours = 0; - return ((Hours + 12) * 60L + Minutes) * 60L + Seconds; - default: - return (-1); - } - /* NOTREACHED */ -} - - -/* Year is either - * A negative number, which means to use its absolute value (why?) - * A number from 0 to 99, which means a year from 1900 to 1999, or - * The actual year (>=100). - */ -static time_t -Convert(time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes, - time_t Seconds, MERIDIAN Meridian, DSTMODE DSTmode) -{ - static int DaysInMonth[12] = { - 31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 - }; - time_t tod; - time_t julian; - int i; - - if (Year < 0) - Year = -Year; - if (Year < 69) - Year += 2000; - else if (Year < 100) { - Year += 1900; - if (Year < YEAR_EPOCH) - Year += 100; - } - DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) - ? 29 : 28; - /* XXX Sloppily check for 2038 if time_t is 32 bits */ - if (Year < YEAR_EPOCH || - (sizeof(time_t) == sizeof(int) && Year > 2038) || - Month < 1 || Month > 12 || - /* Lint fluff: "conversion from long may lose accuracy" */ - Day < 1 || Day > DaysInMonth[(int)--Month]) - return (-1); - - for (julian = Day - 1, i = 0; i < Month; i++) - julian += DaysInMonth[i]; - - for (i = YEAR_EPOCH; i < Year; i++) - julian += 365 + (i % 4 == 0); - julian *= SECSPERDAY; - julian += yyTimezone * 60L; - - if ((tod = ToSeconds(Hours, Minutes, Seconds, Meridian)) < 0) - return (-1); - julian += tod; - if ((DSTmode == DSTon) || - (DSTmode == DSTmaybe && localtime(&julian)->tm_isdst)) - julian -= 60 * 60; - return (julian); -} - - -static time_t -DSTcorrect(time_t Start, time_t Future) -{ - time_t StartDay; - time_t FutureDay; - - StartDay = (localtime(&Start)->tm_hour + 1) % 24; - FutureDay = (localtime(&Future)->tm_hour + 1) % 24; - return (Future - Start) + (StartDay - FutureDay) * 60L * 60L; -} - - -static time_t -RelativeDate(time_t Start, time_t DayOrdinal, time_t DayNumber) -{ - struct tm *tm; - time_t now; - - now = Start; - tm = localtime(&now); - now += SECSPERDAY * ((DayNumber - tm->tm_wday + 7) % 7); - now += 7 * SECSPERDAY * (DayOrdinal <= 0 ? DayOrdinal : DayOrdinal - 1); - return DSTcorrect(Start, now); -} - - -static time_t -RelativeMonth(time_t Start, time_t RelMonth) -{ - struct tm *tm; - time_t Month; - time_t Year; - - if (RelMonth == 0) - return (0); - tm = localtime(&Start); - Month = 12 * (tm->tm_year + 1900) + tm->tm_mon + RelMonth; - Year = Month / 12; - Month = Month % 12 + 1; - return DSTcorrect(Start, - Convert(Month, (time_t)tm->tm_mday, Year, - (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, - MER24, DSTmaybe)); -} - - -static int -lookup(char *buff) -{ - size_t len; - char *p, *q; - int i, abbrev; - const TABLE *tp; - - /* Make it lowercase. */ - for (p = buff; *p; p++) - if (isupper(*p)) - *p = tolower(*p); - - if (strcmp(buff, "am") == 0 || strcmp(buff, "a.m.") == 0) { - yylval.Meridian = MERam; - return (tMERIDIAN); - } - if (strcmp(buff, "pm") == 0 || strcmp(buff, "p.m.") == 0) { - yylval.Meridian = MERpm; - return (tMERIDIAN); - } - - len = strlen(buff); - /* See if we have an abbreviation for a month. */ - if (len == 3) - abbrev = 1; - else if (len == 4 && buff[3] == '.') { - abbrev = 1; - buff[3] = '\0'; - --len; - } else - abbrev = 0; - - for (tp = MonthDayTable; tp->name; tp++) { - if (abbrev) { - if (strncmp(buff, tp->name, 3) == 0) { - yylval.Number = tp->value; - return (tp->type); - } - } else if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return (tp->type); - } - } - - for (tp = TimezoneTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return (tp->type); - } - - if (strcmp(buff, "dst") == 0) - return (tDST); - - for (tp = UnitsTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return (tp->type); - } - - /* Strip off any plural and try the units table again. */ - if (len != 0 && buff[len - 1] == 's') { - buff[len - 1] = '\0'; - for (tp = UnitsTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return (tp->type); - } - buff[len - 1] = 's'; /* Put back for "this" in OtherTable. */ - } - - for (tp = OtherTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return (tp->type); - } - - /* Military timezones. */ - if (len == 1 && isalpha(*buff)) { - for (tp = MilitaryTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return (tp->type); - } - } - - /* Drop out any periods and try the timezone table again. */ - for (i = 0, p = q = buff; *q; q++) - if (*q != '.') - *p++ = *q; - else - i++; - *p = '\0'; - if (i) - for (tp = TimezoneTable; tp->name; tp++) - if (strcmp(buff, tp->name) == 0) { - yylval.Number = tp->value; - return (tp->type); - } - - return (tID); -} - - -static int -yylex(void) -{ - char c, *p, buff[20]; - int count, sign; - - for (;;) { - while (isspace(*yyInput)) - yyInput++; - - if (isdigit(c = *yyInput) || c == '-' || c == '+') { - if (c == '-' || c == '+') { - sign = c == '-' ? -1 : 1; - if (!isdigit(*++yyInput)) - /* skip the '-' sign */ - continue; - } - else - sign = 0; - - for (yylval.Number = 0; isdigit(c = *yyInput++); ) - yylval.Number = 10 * yylval.Number + c - '0'; - yyInput--; - if (sign < 0) - yylval.Number = -yylval.Number; - return sign ? tSNUMBER : tUNUMBER; - } - - if (isalpha(c)) { - for (p = buff; isalpha(c = *yyInput++) || c == '.'; ) - if (p < &buff[sizeof buff - 1]) - *p++ = c; - *p = '\0'; - yyInput--; - return lookup(buff); - } - if (c != '(') - return *yyInput++; - - count = 0; - do { - c = *yyInput++; - if (c == '\0') - return (c); - if (c == '(') - count++; - else if (c == ')') - count--; - } while (count > 0); - } -} - -/* Yield A - B, measured in seconds. */ -static long -difftm(struct tm *a, struct tm *b) -{ - int ay = a->tm_year + (YEAR_TMORIGIN - 1); - int by = b->tm_year + (YEAR_TMORIGIN - 1); - int days = ( - /* difference in day of year */ - a->tm_yday - b->tm_yday - /* + intervening leap days */ - + ((ay >> 2) - (by >> 2)) - - (ay/100 - by/100) - + ((ay/100 >> 2) - (by/100 >> 2)) - /* + difference in years * 365 */ - + (long)(ay-by) * 365); - return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour)) - + (a->tm_min - b->tm_min)) + (a->tm_sec - b->tm_sec)); -} - -/* - * date_parse() - * - * Returns the number of seconds since the Epoch corresponding to the date. - */ -time_t -date_parse(const char *p) -{ - struct tm gmt, tm; - time_t Start, tod, nowtime, tz; - - yyInput = p; - - if (time(&nowtime) == -1 || !gmtime_r(&nowtime, &gmt) || - !localtime_r(&nowtime, &tm)) - return -1; - - tz = difftm(&gmt, &tm) / 60; - - if (tm.tm_isdst) - tz += 60; - - yyYear = tm.tm_year + 1900; - yyMonth = tm.tm_mon + 1; - yyDay = tm.tm_mday; - yyTimezone = tz; - yyDSTmode = DSTmaybe; - yyHour = 0; - yyMinutes = 0; - yySeconds = 0; - yyMeridian = MER24; - yyRelSeconds = 0; - yyRelMonth = 0; - yyHaveDate = 0; - yyHaveDay = 0; - yyHaveRel = 0; - yyHaveTime = 0; - yyHaveZone = 0; - - if (yyparse() || yyHaveTime > 1 || yyHaveZone > 1 || - yyHaveDate > 1 || yyHaveDay > 1) - return (-1); - - if (yyHaveDate || yyHaveTime || yyHaveDay) { - Start = Convert(yyMonth, yyDay, yyYear, yyHour, yyMinutes, - yySeconds, yyMeridian, yyDSTmode); - if (Start < 0) - return (-1); - } else { - Start = nowtime; - if (!yyHaveRel) - Start -= ((tm.tm_hour * 60L + tm.tm_min) * 60L) + - tm.tm_sec; - } - - Start += yyRelSeconds; - Start += RelativeMonth(Start, yyRelMonth); - - if (yyHaveDay && !yyHaveDate) { - tod = RelativeDate(Start, yyDayOrdinal, yyDayNumber); - Start += tod; - } - - return Start; -} - -#if defined(TEST) -/* ARGSUSED */ -int -main(int argc, char **argv) -{ - char buff[128]; - time_t d; - - (void)printf("Enter date, or blank line to exit.\n\t> "); - (void)fflush(stdout); - while (fgets(buff, sizeof(buff), stdin) && buff[0]) { - d = date_parse(buff); - if (d == -1) - (void)printf("Bad format - couldn't convert.\n"); - else - (void)printf("%s", ctime(&d)); - (void)printf("\t> "); - (void)fflush(stdout); - } - - return (0); -} -#endif /* defined(TEST) */ Index: vendor/OpenBSD/dist/usr.bin/rcs/rlog.1 =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/rlog.1 (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/rlog.1 (nonexistent) @@ -1,196 +0,0 @@ -.\" $OpenBSD: rlog.1,v 1.24 2010/09/03 11:09:29 jmc Exp $ -.\" -.\" Copyright (c) 2005 Xavier Santolaria -.\" All rights reserved. -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.Dd $Mdocdate: September 3 2010 $ -.Dt RLOG 1 -.Os -.Sh NAME -.Nm rlog -.Nd display information about RCS files -.Sh SYNOPSIS -.Nm -.Op Fl bhLNRtV -.Op Fl d Ns Ar dates -.Op Fl l Ns Op Ar lockers -.Op Fl r Ns Op Ar revs -.Op Fl s Ns Ar states -.Op Fl w Ns Op Ar logins -.Op Fl x Ns Ar suffixes -.Op Fl z Ns Ar tz -.Ar -.Sh DESCRIPTION -The -.Nm -program displays information about RCS files. -.Pp -A file's complete RCS history can be displayed -(the default if no options are specified) -or a subset of its history log can be requested, -depending on which options are specified. -RCS keywords are displayed using the -.Xr ident 1 -utility. -.Pp -The following options are supported: -.Bl -tag -width Ds -.It Fl b -Print information about revisions of the default branch only. -.It Fl d Ns Ar dates -Specify revisions with dates matching the specification. -The specification might be as follows: -.Bl -tag -width Ds -.It date1date1 -Select all revisions between -.Ar date1 -and -.Ar date2 . -.It -Select all revisions before -.Ar date . -.It >date or date< -Select all revisions after -.Ar date . -.It date -Select the latest revision before or equal to -.Ar date . -.El -.Pp -The -.Sq \*(Gt -and -.Sq \*(Lt -characters can be followed by the -.Sq = -character to imply an inclusive specification. -Several specifications can be used by separating them with the -.Sq \&; -character. -.Pp -See also the -.Fl z -option, below. -.It Fl h -Print the RCS header, -describing a file's branch, lock details, symbolic names, etc. -.It Fl L -Ignore RCS files with no locks set. -.It Fl l Ns Op Ar lockers -Print information about locked revisions only. -If a comma-separated list of login names is specified, -ignore all locks other than those held in the list. -.It Fl N -Do not print symbolic names. -.It Fl R -Print name of RCS file only. -.It Fl r Ns Op Ar revs -Specify revision(s) to list: -.Bl -tag -width Ds -.It rev1,rev2,... -A list of revisions is specified by separating names or numbers -of revisions by the -.Sq \&, -character. -.It rev1:rev2 -List all revisions between -.Ar rev1 -and -.Ar rev2 -(they must be on the same branch). -.It :rev -List all revisions since the beginning of the branch until -.Ar rev -included. -.It rev: -List all revisions of the branch beginning with -.Ar rev . -.It branch -List all revisions of a branch. -.It branch. -List the latest revision of the branch -.Ar branch . -.It branch1:branch2 -List all revisions of branches between -.Ar branch1 -and -.Ar branch2 . -.El -.Pp -Without argument, the -.Fl r -option means the latest revision of the default branch. -.It Fl s Ns Ar states -Print information about revisions whose state matches one of the -specified -.Ar states . -Multiple states may be specified as a comma-separated list. -.It Fl t -Print header and description only. -.It Fl V -Print RCS's version number. -.It Fl w Ns Op Ar logins -Print information about revisions checked in by users specified -in a comma-separated list. -If -.Ar logins -is omitted, the user's login is assumed. -.It Fl x Ns Ar suffixes -Specifies the suffixes for RCS files. -Suffixes should be separated by the -.Sq / -character. -.It Fl z Ns Ar tz -Specify the date output format. -The -.Ar tz -argument should be a numeric UTC offset -(e.g. +02:45 would specify an offset of 2 hours 45 minutes). -.Sq LT -may instead be used to specify local time. -If no argument is given, a default format is used. -This option is also used to set the default time zone for -dates used in the -.Fl d -option. -.El -.Sh ENVIRONMENT -.Bl -tag -width RCSINIT -.It Ev RCSINIT -If set, this variable should contain a list of space-delimited options that -are prepended to the argument list. -.El -.Sh EXIT STATUS -.Ex -std rlog -.Sh EXAMPLES -Print complete information about files: -.Pp -.Dl $ rlog RCS/* -.Pp -Print the names of RCS files with locks set: -.Pp -.Dl $ rlog -L -R RCS/* -.Sh SEE ALSO -.Xr ci 1 , -.Xr co 1 , -.Xr ident 1 , -.Xr rcs 1 , -.Xr rcsclean 1 , -.Xr rcsdiff 1 , -.Xr rcsmerge 1 -.Sh STANDARDS -The flags -.Op Fl qT -have no effect and are provided -for compatibility only. Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/rlog.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/xmalloc.c =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/xmalloc.c (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/xmalloc.c (nonexistent) @@ -1,103 +0,0 @@ -/* $OpenBSD: xmalloc.c,v 1.8 2015/03/26 15:17:30 okan Exp $ */ -/* - * Author: Tatu Ylonen - * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland - * All rights reserved - * Versions of malloc and friends that check their results, and never return - * failure (they call fatal if they encounter an error). - * - * As far as I am concerned, the code I have written for this software - * can be used freely for any purpose. Any derived versions of this - * software must be clearly marked as such, and if the derived work is - * incompatible with the protocol description in the RFC file, it must be - * called by a name other than "ssh" or "Secure Shell". - */ - -#include -#include -#include -#include -#include -#include - -#include "xmalloc.h" - -void * -xmalloc(size_t size) -{ - void *ptr; - - if (size == 0) - errx(1, "xmalloc: zero size"); - ptr = malloc(size); - if (ptr == NULL) - errx(1, - "xmalloc: out of memory (allocating %zu bytes)", - size); - return ptr; -} - -void * -xcalloc(size_t nmemb, size_t size) -{ - void *ptr; - - if (size == 0 || nmemb == 0) - errx(1, "xcalloc: zero size"); - if (SIZE_MAX / nmemb < size) - errx(1, "xcalloc: nmemb * size > SIZE_MAX"); - ptr = calloc(nmemb, size); - if (ptr == NULL) - errx(1, "xcalloc: out of memory (allocating %zu bytes)", - (size * nmemb)); - return ptr; -} - -void * -xreallocarray(void *ptr, size_t nmemb, size_t size) -{ - void *new_ptr; - - new_ptr = reallocarray(ptr, nmemb, size); - if (new_ptr == NULL) - errx(1, "xreallocarray: out of memory (new_size %zu bytes)", - nmemb * size); - return new_ptr; -} - -void -xfree(void *ptr) -{ - if (ptr == NULL) - errx(1, "xfree: NULL pointer given as argument"); - free(ptr); -} - -char * -xstrdup(const char *str) -{ - size_t len; - char *cp; - - len = strlen(str) + 1; - cp = xmalloc(len); - if (strlcpy(cp, str, len) >= len) - errx(1, "xstrdup: string truncated"); - return cp; -} - -int -xasprintf(char **ret, const char *fmt, ...) -{ - va_list ap; - int i; - - va_start(ap, fmt); - i = vasprintf(ret, fmt, ap); - va_end(ap); - - if (i < 0 || *ret == NULL) - errx(1, "xasprintf: could not allocate memory"); - - return (i); -} Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/xmalloc.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/rcsdiff.c =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/rcsdiff.c (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/rcsdiff.c (nonexistent) @@ -1,464 +0,0 @@ -/* $OpenBSD: rcsdiff.c,v 1.82 2015/01/16 06:40:11 deraadt Exp $ */ -/* - * Copyright (c) 2005 Joris Vink - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "rcsprog.h" -#include "diff.h" - -static int rcsdiff_file(RCSFILE *, RCSNUM *, const char *, int); -static int rcsdiff_rev(RCSFILE *, RCSNUM *, RCSNUM *, int); -static void push_ignore_pats(char *); - -static int quiet; -static int kflag = RCS_KWEXP_ERR; -static char *diff_ignore_pats; - -int -rcsdiff_main(int argc, char **argv) -{ - int fd, i, ch, dflags, status; - RCSNUM *rev1, *rev2; - RCSFILE *file; - char fpath[PATH_MAX], *rev_str1, *rev_str2; - const char *errstr; - - rev1 = rev2 = NULL; - rev_str1 = rev_str2 = NULL; - status = D_SAME; - dflags = 0; - - if (strlcpy(diffargs, "diff", sizeof(diffargs)) >= sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - - while ((ch = rcs_getopt(argc, argv, "abC:cdI:ik:npqr:TtU:uVwx::z::")) != -1) { - switch (ch) { - case 'a': - if (strlcat(diffargs, " -a", sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - dflags |= D_FORCEASCII; - break; - case 'b': - if (strlcat(diffargs, " -b", sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - dflags |= D_FOLDBLANKS; - break; - case 'C': - (void)strlcat(diffargs, " -C", sizeof(diffargs)); - if (strlcat(diffargs, rcs_optarg, sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - diff_context = strtonum(rcs_optarg, 0, INT_MAX, &errstr); - if (errstr) - errx(D_ERROR, "context is %s: %s", - errstr, rcs_optarg); - diff_format = D_CONTEXT; - break; - case 'c': - if (strlcat(diffargs, " -c", sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - diff_format = D_CONTEXT; - break; - case 'd': - if (strlcat(diffargs, " -d", sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - dflags |= D_MINIMAL; - break; - case 'i': - if (strlcat(diffargs, " -i", sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - dflags |= D_IGNORECASE; - break; - case 'I': - (void)strlcat(diffargs, " -I", sizeof(diffargs)); - if (strlcat(diffargs, rcs_optarg, sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - push_ignore_pats(rcs_optarg); - break; - case 'k': - kflag = rcs_kflag_get(rcs_optarg); - if (RCS_KWEXP_INVAL(kflag)) { - warnx("invalid RCS keyword substitution mode"); - (usage)(); - } - break; - case 'n': - if (strlcat(diffargs, " -n", sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - diff_format = D_RCSDIFF; - break; - case 'p': - if (strlcat(diffargs, " -p", sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - dflags |= D_PROTOTYPE; - break; - case 'q': - quiet = 1; - break; - case 'r': - rcs_setrevstr2(&rev_str1, &rev_str2, rcs_optarg); - break; - case 'T': - /* - * kept for compatibility - */ - break; - case 't': - if (strlcat(diffargs, " -t", sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - dflags |= D_EXPANDTABS; - break; - case 'U': - (void)strlcat(diffargs, " -U", sizeof(diffargs)); - if (strlcat(diffargs, rcs_optarg, sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - diff_context = strtonum(rcs_optarg, 0, INT_MAX, &errstr); - if (errstr) - errx(D_ERROR, "context is %s: %s", - errstr, rcs_optarg); - diff_format = D_UNIFIED; - break; - case 'u': - if (strlcat(diffargs, " -u", sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - diff_format = D_UNIFIED; - break; - case 'V': - printf("%s\n", rcs_version); - exit(0); - case 'w': - if (strlcat(diffargs, " -w", sizeof(diffargs)) >= - sizeof(diffargs)) - errx(D_ERROR, "diffargs too long"); - dflags |= D_IGNOREBLANKS; - break; - case 'x': - /* Use blank extension if none given. */ - rcs_suffixes = rcs_optarg ? rcs_optarg : ""; - break; - case 'z': - timezone_flag = rcs_optarg; - break; - default: - (usage)(); - } - } - - argc -= rcs_optind; - argv += rcs_optind; - - if (argc == 0) { - warnx("no input file"); - (usage)(); - } - - if (diff_ignore_pats != NULL) { - char buf[BUFSIZ]; - int error; - - diff_ignore_re = xmalloc(sizeof(*diff_ignore_re)); - if ((error = regcomp(diff_ignore_re, diff_ignore_pats, - REG_NEWLINE | REG_EXTENDED)) != 0) { - regerror(error, diff_ignore_re, buf, sizeof(buf)); - if (*diff_ignore_pats != '\0') - errx(D_ERROR, "%s: %s", diff_ignore_pats, buf); - else - errx(D_ERROR, "%s", buf); - } - } - - for (i = 0; i < argc; i++) { - fd = rcs_choosefile(argv[i], fpath, sizeof(fpath)); - if (fd < 0) { - warn("%s", fpath); - continue; - } - - if ((file = rcs_open(fpath, fd, - RCS_READ|RCS_PARSE_FULLY)) == NULL) - continue; - - rcs_kwexp_set(file, kflag); - - if (rev_str1 != NULL) { - if ((rev1 = rcs_getrevnum(rev_str1, file)) == NULL) - errx(D_ERROR, "bad revision number"); - } - if (rev_str2 != NULL) { - if ((rev2 = rcs_getrevnum(rev_str2, file)) == NULL) - errx(D_ERROR, "bad revision number"); - } - - if (!quiet) { - fprintf(stderr, "%s\n", RCS_DIFF_DIV); - fprintf(stderr, "RCS file: %s\n", fpath); - } - - diff_file = argv[i]; - - /* No revisions given. */ - if (rev_str1 == NULL) - status = rcsdiff_file(file, file->rf_head, argv[i], - dflags); - /* One revision given. */ - else if (rev_str2 == NULL) - status = rcsdiff_file(file, rev1, argv[i], dflags); - /* Two revisions given. */ - else - status = rcsdiff_rev(file, rev1, rev2, dflags); - - rcs_close(file); - - if (rev1 != NULL) { - rcsnum_free(rev1); - rev1 = NULL; - } - if (rev2 != NULL) { - rcsnum_free(rev2); - rev2 = NULL; - } - } - - return (status); -} - -__dead void -rcsdiff_usage(void) -{ - fprintf(stderr, - "usage: rcsdiff [-cnquV] [-kmode] [-rrev] [-xsuffixes] [-ztz]\n" - " [diff_options] file ...\n"); - - exit(D_ERROR); -} - -static int -rcsdiff_file(RCSFILE *file, RCSNUM *rev, const char *filename, int dflags) -{ - int ret, fd; - time_t t; - struct stat st; - char *path1, *path2; - BUF *b1, *b2; - char rbuf[RCS_REV_BUFSZ]; - struct tm *tb; - struct timeval tv[2], tv2[2]; - - memset(&tv, 0, sizeof(tv)); - memset(&tv2, 0, sizeof(tv2)); - - ret = D_ERROR; - b1 = b2 = NULL; - - diff_rev1 = rev; - diff_rev2 = NULL; - path1 = path2 = NULL; - - if ((fd = open(filename, O_RDONLY)) == -1) { - warn("%s", filename); - goto out; - } - - rcsnum_tostr(rev, rbuf, sizeof(rbuf)); - if (!quiet) { - fprintf(stderr, "retrieving revision %s\n", rbuf); - fprintf(stderr, "%s -r%s %s\n", diffargs, rbuf, filename); - } - - if ((b1 = rcs_getrev(file, rev)) == NULL) { - warnx("failed to retrieve revision %s", rbuf); - goto out; - } - - b1 = rcs_kwexp_buf(b1, file, rev); - tv[0].tv_sec = rcs_rev_getdate(file, rev); - tv[1].tv_sec = tv[0].tv_sec; - - if ((b2 = buf_load(filename)) == NULL) { - warnx("failed to load file: `%s'", filename); - goto out; - } - - /* XXX - GNU uses GMT */ - if (fstat(fd, &st) == -1) - err(D_ERROR, "%s", filename); - - tb = gmtime(&st.st_mtime); - t = mktime(tb); - - tv2[0].tv_sec = t; - tv2[1].tv_sec = t; - - (void)xasprintf(&path1, "%s/diff1.XXXXXXXXXX", rcs_tmpdir); - buf_write_stmp(b1, path1); - - buf_free(b1); - b1 = NULL; - - if (utimes(path1, (const struct timeval *)&tv) < 0) - warn("utimes"); - - (void)xasprintf(&path2, "%s/diff2.XXXXXXXXXX", rcs_tmpdir); - buf_write_stmp(b2, path2); - - buf_free(b2); - b2 = NULL; - - if (utimes(path2, (const struct timeval *)&tv2) < 0) - warn("utimes"); - - ret = diffreg(path1, path2, NULL, dflags); - -out: - if (fd != -1) - (void)close(fd); - if (b1 != NULL) - buf_free(b1); - if (b2 != NULL) - buf_free(b2); - if (path1 != NULL) - xfree(path1); - if (path2 != NULL) - xfree(path2); - - return (ret); -} - -static int -rcsdiff_rev(RCSFILE *file, RCSNUM *rev1, RCSNUM *rev2, int dflags) -{ - struct timeval tv[2], tv2[2]; - BUF *b1, *b2; - int ret; - char *path1, *path2, rbuf1[RCS_REV_BUFSZ], rbuf2[RCS_REV_BUFSZ]; - - ret = D_ERROR; - b1 = b2 = NULL; - memset(&tv, 0, sizeof(tv)); - memset(&tv2, 0, sizeof(tv2)); - - diff_rev1 = rev1; - diff_rev2 = rev2; - path1 = path2 = NULL; - - rcsnum_tostr(rev1, rbuf1, sizeof(rbuf1)); - if (!quiet) - fprintf(stderr, "retrieving revision %s\n", rbuf1); - - if ((b1 = rcs_getrev(file, rev1)) == NULL) { - warnx("failed to retrieve revision %s", rbuf1); - goto out; - } - - b1 = rcs_kwexp_buf(b1, file, rev1); - tv[0].tv_sec = rcs_rev_getdate(file, rev1); - tv[1].tv_sec = tv[0].tv_sec; - - rcsnum_tostr(rev2, rbuf2, sizeof(rbuf2)); - if (!quiet) - fprintf(stderr, "retrieving revision %s\n", rbuf2); - - if ((b2 = rcs_getrev(file, rev2)) == NULL) { - warnx("failed to retrieve revision %s", rbuf2); - goto out; - } - - b2 = rcs_kwexp_buf(b2, file, rev2); - tv2[0].tv_sec = rcs_rev_getdate(file, rev2); - tv2[1].tv_sec = tv2[0].tv_sec; - - if (!quiet) - fprintf(stderr, "%s -r%s -r%s\n", diffargs, rbuf1, rbuf2); - - (void)xasprintf(&path1, "%s/diff1.XXXXXXXXXX", rcs_tmpdir); - buf_write_stmp(b1, path1); - - buf_free(b1); - b1 = NULL; - - if (utimes(path1, (const struct timeval *)&tv) < 0) - warn("utimes"); - - (void)xasprintf(&path2, "%s/diff2.XXXXXXXXXX", rcs_tmpdir); - buf_write_stmp(b2, path2); - - buf_free(b2); - b2 = NULL; - - if (utimes(path2, (const struct timeval *)&tv2) < 0) - warn("utimes"); - - ret = diffreg(path1, path2, NULL, dflags); - -out: - if (b1 != NULL) - buf_free(b1); - if (b2 != NULL) - buf_free(b2); - if (path1 != NULL) - xfree(path1); - if (path2 != NULL) - xfree(path2); - - return (ret); -} - -static void -push_ignore_pats(char *pattern) -{ - size_t len; - - if (diff_ignore_pats == NULL) { - len = strlen(pattern) + 1; - diff_ignore_pats = xmalloc(len); - strlcpy(diff_ignore_pats, pattern, len); - } else { - /* old + "|" + new + NUL */ - len = strlen(diff_ignore_pats) + strlen(pattern) + 2; - diff_ignore_pats = xreallocarray(diff_ignore_pats, len, 1); - strlcat(diff_ignore_pats, "|", len); - strlcat(diff_ignore_pats, pattern, len); - } -} Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/rcsdiff.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/xmalloc.h =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/xmalloc.h (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/xmalloc.h (nonexistent) @@ -1,31 +0,0 @@ -/* $OpenBSD: xmalloc.h,v 1.2 2014/12/01 21:58:46 deraadt Exp $ */ - -/* - * Author: Tatu Ylonen - * Copyright (c) 1995 Tatu Ylonen , Espoo, Finland - * All rights reserved - * Created: Mon Mar 20 22:09:17 1995 ylo - * - * Versions of malloc and friends that check their results, and never return - * failure (they call fatal if they encounter an error). - * - * As far as I am concerned, the code I have written for this software - * can be used freely for any purpose. Any derived versions of this - * software must be clearly marked as such, and if the derived work is - * incompatible with the protocol description in the RFC file, it must be - * called by a name other than "ssh" or "Secure Shell". - */ - -#ifndef XMALLOC_H -#define XMALLOC_H - -void *xmalloc(size_t); -void *xcalloc(size_t, size_t); -void *xreallocarray(void *, size_t, size_t); -void xfree(void *); -char *xstrdup(const char *); -int xasprintf(char **, const char *, ...) - __attribute__((__format__ (printf, 2, 3))) - __attribute__((__nonnull__ (2))); - -#endif /* XMALLOC_H */ Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/xmalloc.h ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/ident.1 =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/ident.1 (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/ident.1 (nonexistent) @@ -1,79 +0,0 @@ -.\" $OpenBSD: ident.1,v 1.12 2013/06/29 09:08:41 jmc Exp $ -.\" -.\" Copyright (c) 2005 Xavier Santolaria -.\" All rights reserved. -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.Dd $Mdocdate: June 29 2013 $ -.Dt IDENT 1 -.Os -.Sh NAME -.Nm ident -.Nd identify RCS keyword strings in files -.Sh SYNOPSIS -.Nm -.Op Fl qV -.Op Ar -.Sh DESCRIPTION -The -.Nm -program searches for the pattern $keyword:... $ from the -.Ar files -specified as argument (or standard input if none are given). -See the KEYWORD SUBSTITUTION section of -.Xr rcs 1 -for more information. -.Pp -The following options are supported: -.Bl -tag -width "XXX" -.It Fl q -Quiet mode: suppress warnings if no pattern found. -.It Fl V -Display version information and exit. -.El -.Sh EXIT STATUS -.Ex -std ident -.Sh EXAMPLES -Given the following source code in file -.Pa foo.c : -.Bd -literal -offset indent -#include \*(Ltstdio.h\*(Gt - -static char const rcsid[] = - "$\&Id: foo.c,v 1.2 2005/11/18 09:34:51 xsa Exp $"; - -int -main(void) { - printf("%s\en", rcsid); - return (0); -} -.Ed -.Pp -Compile it and run -.Nm : -.Bd -literal -offset indent -$ ident foo.c foo.o -foo.c: - $\&Id: foo.c,v 1.2 2005/11/18 09:34:51 xsa Exp $ -foo.o: - $\&Id: foo.c,v 1.2 2005/11/18 09:34:51 xsa Exp $ -.Ed -.Sh SEE ALSO -.Xr ci 1 , -.Xr co 1 , -.Xr cvs 1 , -.Xr rcs 1 , -.Xr rcsclean 1 , -.Xr rcsdiff 1 , -.Xr rcsmerge 1 , -.Xr rlog 1 Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/ident.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/rcsmerge.c =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/rcsmerge.c (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/rcsmerge.c (nonexistent) @@ -1,193 +0,0 @@ -/* $OpenBSD: rcsmerge.c,v 1.55 2015/01/16 06:40:11 deraadt Exp $ */ -/* - * Copyright (c) 2005, 2006 Xavier Santolaria - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include -#include - -#include "rcsprog.h" -#include "diff.h" - -int -rcsmerge_main(int argc, char **argv) -{ - int fd, ch, flags, kflag, status; - char fpath[PATH_MAX], r1[RCS_REV_BUFSZ], r2[RCS_REV_BUFSZ]; - char *rev_str1, *rev_str2; - RCSFILE *file; - RCSNUM *rev1, *rev2; - BUF *bp; - - flags = 0; - status = D_ERROR; - rev1 = rev2 = NULL; - rev_str1 = rev_str2 = NULL; - - while ((ch = rcs_getopt(argc, argv, "AEek:p::q::r::TVx::z:")) != -1) { - switch (ch) { - case 'A': - /* - * kept for compatibility - */ - break; - case 'E': - flags |= MERGE_EFLAG; - flags |= MERGE_OFLAG; - break; - case 'e': - flags |= MERGE_EFLAG; - break; - case 'k': - kflag = rcs_kflag_get(rcs_optarg); - if (RCS_KWEXP_INVAL(kflag)) { - warnx("invalid RCS keyword substitution mode"); - (usage)(); - } - break; - case 'p': - rcs_setrevstr2(&rev_str1, &rev_str2, rcs_optarg); - flags |= PIPEOUT; - break; - case 'q': - rcs_setrevstr2(&rev_str1, &rev_str2, rcs_optarg); - flags |= QUIET; - break; - case 'r': - rcs_setrevstr2(&rev_str1, &rev_str2, - rcs_optarg ? rcs_optarg : ""); - break; - case 'T': - /* - * kept for compatibility - */ - break; - case 'V': - printf("%s\n", rcs_version); - exit(0); - case 'x': - /* Use blank extension if none given. */ - rcs_suffixes = rcs_optarg ? rcs_optarg : ""; - break; - case 'z': - timezone_flag = rcs_optarg; - break; - default: - (usage)(); - } - } - - argc -= rcs_optind; - argv += rcs_optind; - - if (rev_str1 == NULL) { - warnx("no base revision number given"); - (usage)(); - } - - if (argc < 1) { - warnx("no input file"); - (usage)(); - } - - if (argc > 2 || (argc == 2 && argv[1] != NULL)) - warnx("warning: excess arguments ignored"); - - if ((fd = rcs_choosefile(argv[0], fpath, sizeof(fpath))) < 0) - err(status, "%s", fpath); - - if (!(flags & QUIET)) - (void)fprintf(stderr, "RCS file: %s\n", fpath); - - if ((file = rcs_open(fpath, fd, RCS_READ)) == NULL) - return (status); - - if (strcmp(rev_str1, "") == 0) { - rev1 = rcsnum_alloc(); - rcsnum_cpy(file->rf_head, rev1, 0); - } else if ((rev1 = rcs_getrevnum(rev_str1, file)) == NULL) - errx(D_ERROR, "invalid revision: %s", rev_str1); - - if (rev_str2 != NULL && strcmp(rev_str2, "") != 0) { - if ((rev2 = rcs_getrevnum(rev_str2, file)) == NULL) - errx(D_ERROR, "invalid revision: %s", rev_str2); - } else { - rev2 = rcsnum_alloc(); - rcsnum_cpy(file->rf_head, rev2, 0); - } - - if (rcsnum_cmp(rev1, rev2, 0) == 0) - goto out; - - if ((bp = rcs_diff3(file, argv[0], rev1, rev2, flags)) == NULL) - errx(D_ERROR, "failed to merge"); - - if (!(flags & QUIET)) { - (void)rcsnum_tostr(rev1, r1, sizeof(r1)); - (void)rcsnum_tostr(rev2, r2, sizeof(r2)); - - (void)fprintf(stderr, "Merging differences between %s and " - "%s into %s%s\n", r1, r2, argv[0], - (flags & PIPEOUT) ? "; result to stdout":""); - } - - if (diff3_conflicts != 0) - status = D_OVERLAPS; - else - status = 0; - - if (flags & PIPEOUT) - buf_write_fd(bp, STDOUT_FILENO); - else { - /* XXX mode */ - if (buf_write(bp, argv[0], 0644) < 0) - warnx("buf_write failed"); - - } - - buf_free(bp); - -out: - rcs_close(file); - - if (rev1 != NULL) - rcsnum_free(rev1); - if (rev2 != NULL) - rcsnum_free(rev2); - - return (status); -} - -__dead void -rcsmerge_usage(void) -{ - fprintf(stderr, - "usage: rcsmerge [-EV] [-kmode] [-p[rev]] [-q[rev]]\n" - " [-xsuffixes] [-ztz] -rrev file ...\n"); - - exit(D_ERROR); -} Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/rcsmerge.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/rcsparse.c =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/rcsparse.c (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/rcsparse.c (nonexistent) @@ -1,1271 +0,0 @@ -/* $OpenBSD: rcsparse.c,v 1.14 2014/12/01 21:58:46 deraadt Exp $ */ -/* - * Copyright (c) 2010 Tobias Stoeckmann - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rcs.h" -#include "rcsparse.h" -#include "xmalloc.h" - -#define RCS_BUFSIZE 16384 -#define RCS_BUFEXTSIZE 8192 - -/* RCS token types */ -#define RCS_TOK_HEAD (1 << 0) -#define RCS_TOK_BRANCH (1 << 1) -#define RCS_TOK_ACCESS (1 << 2) -#define RCS_TOK_SYMBOLS (1 << 3) -#define RCS_TOK_LOCKS (1 << 4) -#define RCS_TOK_STRICT (1 << 5) -#define RCS_TOK_COMMENT (1 << 6) -#define RCS_TOK_COMMITID (1 << 7) -#define RCS_TOK_EXPAND (1 << 8) -#define RCS_TOK_DESC (1 << 9) -#define RCS_TOK_DATE (1 << 10) -#define RCS_TOK_AUTHOR (1 << 11) -#define RCS_TOK_STATE (1 << 12) -#define RCS_TOK_BRANCHES (1 << 13) -#define RCS_TOK_NEXT (1 << 14) -#define RCS_TOK_LOG (1 << 15) -#define RCS_TOK_TEXT (1 << 16) -#define RCS_TOK_COLON (1 << 17) -#define RCS_TOK_COMMA (1 << 18) -#define RCS_TOK_SCOLON (1 << 19) - -#define RCS_TYPE_STRING (1 << 20) -#define RCS_TYPE_NUMBER (1 << 21) -#define RCS_TYPE_BRANCH (1 << 22) -#define RCS_TYPE_REVISION (1 << 23) -#define RCS_TYPE_LOGIN (1 << 24) -#define RCS_TYPE_STATE (1 << 25) -#define RCS_TYPE_SYMBOL (1 << 26) -#define RCS_TYPE_DATE (1 << 27) -#define RCS_TYPE_KEYWORD (1 << 28) -#define RCS_TYPE_COMMITID (1 << 29) - -#define MANDATORY 0 -#define OPTIONAL 1 - -/* opaque parse data */ -struct rcs_pdata { - char *rp_buf; - size_t rp_blen; - char *rp_bufend; - size_t rp_tlen; - - struct rcs_delta *rp_delta; - int rp_lineno; - int rp_msglineno; - int rp_token; - - union { - RCSNUM *rev; - char *str; - struct tm date; - } rp_value; -}; - -struct rcs_keyword { - const char *k_name; - int k_val; -}; - -struct rcs_section { - int token; - int (*parse)(RCSFILE *, struct rcs_pdata *); - int opt; -}; - -/* this has to be sorted always */ -static const struct rcs_keyword keywords[] = { - { "access", RCS_TOK_ACCESS}, - { "author", RCS_TOK_AUTHOR}, - { "branch", RCS_TOK_BRANCH}, - { "branches", RCS_TOK_BRANCHES}, - { "comment", RCS_TOK_COMMENT}, - { "commitid", RCS_TOK_COMMITID}, - { "date", RCS_TOK_DATE}, - { "desc", RCS_TOK_DESC}, - { "expand", RCS_TOK_EXPAND}, - { "head", RCS_TOK_HEAD}, - { "locks", RCS_TOK_LOCKS}, - { "log", RCS_TOK_LOG}, - { "next", RCS_TOK_NEXT}, - { "state", RCS_TOK_STATE}, - { "strict", RCS_TOK_STRICT}, - { "symbols", RCS_TOK_SYMBOLS}, - { "text", RCS_TOK_TEXT} -}; - -/* parser functions specified in rcs_section structs */ -static int rcsparse_head(RCSFILE *, struct rcs_pdata *); -static int rcsparse_branch(RCSFILE *, struct rcs_pdata *); -static int rcsparse_access(RCSFILE *, struct rcs_pdata *); -static int rcsparse_symbols(RCSFILE *, struct rcs_pdata *); -static int rcsparse_locks(RCSFILE *, struct rcs_pdata *); -static int rcsparse_strict(RCSFILE *, struct rcs_pdata *); -static int rcsparse_comment(RCSFILE *, struct rcs_pdata *); -static int rcsparse_commitid(RCSFILE *, struct rcs_pdata *); -static int rcsparse_expand(RCSFILE *, struct rcs_pdata *); -static int rcsparse_deltarevision(RCSFILE *, struct rcs_pdata *); -static int rcsparse_date(RCSFILE *, struct rcs_pdata *); -static int rcsparse_author(RCSFILE *, struct rcs_pdata *); -static int rcsparse_state(RCSFILE *, struct rcs_pdata *); -static int rcsparse_branches(RCSFILE *, struct rcs_pdata *); -static int rcsparse_next(RCSFILE *, struct rcs_pdata *); -static int rcsparse_textrevision(RCSFILE *, struct rcs_pdata *); -static int rcsparse_log(RCSFILE *, struct rcs_pdata *); -static int rcsparse_text(RCSFILE *, struct rcs_pdata *); - -static int rcsparse_delta(RCSFILE *); -static int rcsparse_deltatext(RCSFILE *); -static int rcsparse_desc(RCSFILE *); - -static int kw_cmp(const void *, const void *); -static int rcsparse(RCSFILE *, struct rcs_section *); -static void rcsparse_growbuf(RCSFILE *); -static int rcsparse_string(RCSFILE *, int); -static int rcsparse_token(RCSFILE *, int); -static void rcsparse_warnx(RCSFILE *, char *, ...); -static int valid_login(char *); -static int valid_commitid(char *); - -/* - * head [REVISION]; - * [branch BRANCH]; - * access [LOGIN ...]; - * symbols [SYMBOL:REVISION ...]; - * locks [LOGIN:REVISION ...]; - * [strict;] - * [comment [@[...]@];] - * [expand [@[...]@];] - */ -static struct rcs_section sec_admin[] = { - { RCS_TOK_HEAD, rcsparse_head, MANDATORY }, - { RCS_TOK_BRANCH, rcsparse_branch, OPTIONAL }, - { RCS_TOK_ACCESS, rcsparse_access, MANDATORY }, - { RCS_TOK_SYMBOLS, rcsparse_symbols, MANDATORY }, - { RCS_TOK_LOCKS, rcsparse_locks, MANDATORY }, - { RCS_TOK_STRICT, rcsparse_strict, OPTIONAL }, - { RCS_TOK_COMMENT, rcsparse_comment, OPTIONAL }, - { RCS_TOK_EXPAND, rcsparse_expand, OPTIONAL }, - { 0, NULL, 0 } -}; - -/* - * REVISION - * date [YY]YY.MM.DD.HH.MM.SS; - * author LOGIN; - * state STATE; - * branches [REVISION ...]; - * next [REVISION]; - * [commitid ID;] - */ -static struct rcs_section sec_delta[] = { - { RCS_TYPE_REVISION, rcsparse_deltarevision, MANDATORY }, - { RCS_TOK_DATE, rcsparse_date, MANDATORY }, - { RCS_TOK_AUTHOR, rcsparse_author, MANDATORY }, - { RCS_TOK_STATE, rcsparse_state, MANDATORY }, - { RCS_TOK_BRANCHES, rcsparse_branches, MANDATORY }, - { RCS_TOK_NEXT, rcsparse_next, MANDATORY }, - { RCS_TOK_COMMITID, rcsparse_commitid, OPTIONAL }, - { 0, NULL, 0 } -}; - -/* - * REVISION - * log @[...]@ - * text @[...]@ - */ -static struct rcs_section sec_deltatext[] = { - { RCS_TYPE_REVISION, rcsparse_textrevision, MANDATORY }, - { RCS_TOK_LOG, rcsparse_log, MANDATORY }, - { RCS_TOK_TEXT, rcsparse_text, MANDATORY }, - { 0, NULL, 0 } -}; - -/* - * rcsparse_init() - * - * Initializes the parsing data structure and parses the admin section of - * RCS file . - * - * Returns 0 on success or 1 on failure. - */ -int -rcsparse_init(RCSFILE *rfp) -{ - struct rcs_pdata *pdp; - - if (rfp->rf_flags & RCS_PARSED) - return (0); - - pdp = xcalloc(1, sizeof(*pdp)); - pdp->rp_buf = xmalloc(RCS_BUFSIZE); - pdp->rp_blen = RCS_BUFSIZE; - pdp->rp_bufend = pdp->rp_buf + pdp->rp_blen - 1; - pdp->rp_token = -1; - pdp->rp_lineno = 1; - pdp->rp_msglineno = 1; - - /* ditch the strict lock */ - rfp->rf_flags &= ~RCS_SLOCK; - rfp->rf_pdata = pdp; - - if (rcsparse(rfp, sec_admin)) { - rcsparse_free(rfp); - return (1); - } - - if ((rfp->rf_flags & RCS_PARSE_FULLY) && - rcsparse_deltatexts(rfp, NULL)) { - rcsparse_free(rfp); - return (1); - } - - rfp->rf_flags |= RCS_SYNCED; - return (0); -} - -/* - * rcsparse_deltas() - * - * Parse deltas. If is not NULL, parse only as far as that - * revision. If is NULL, parse all deltas. - * - * Returns 0 on success or 1 on error. - */ -int -rcsparse_deltas(RCSFILE *rfp, RCSNUM *rev) -{ - int ret; - struct rcs_delta *enddelta; - - if ((rfp->rf_flags & PARSED_DELTAS) || (rfp->rf_flags & RCS_CREATE)) - return (0); - - for (;;) { - ret = rcsparse_delta(rfp); - if (rev != NULL) { - enddelta = TAILQ_LAST(&(rfp->rf_delta), rcs_dlist); - if (enddelta == NULL) - return (1); - - if (rcsnum_cmp(enddelta->rd_num, rev, 0) == 0) - break; - } - - if (ret == 0) { - rfp->rf_flags |= PARSED_DELTAS; - break; - } - else if (ret == -1) - return (1); - } - - return (0); -} - -/* - * rcsparse_deltatexts() - * - * Parse deltatexts. If is not NULL, parse only as far as that - * revision. If is NULL, parse everything. - * - * Returns 0 on success or 1 on error. - */ -int -rcsparse_deltatexts(RCSFILE *rfp, RCSNUM *rev) -{ - int ret; - struct rcs_delta *rdp; - - if ((rfp->rf_flags & PARSED_DELTATEXTS) || - (rfp->rf_flags & RCS_CREATE)) - return (0); - - if (!(rfp->rf_flags & PARSED_DESC)) - if (rcsparse_desc(rfp)) - return (1); - - rdp = (rev != NULL) ? rcs_findrev(rfp, rev) : NULL; - - for (;;) { - if (rdp != NULL && rdp->rd_text != NULL) - break; - ret = rcsparse_deltatext(rfp); - if (ret == 0) { - rfp->rf_flags |= PARSED_DELTATEXTS; - break; - } - else if (ret == -1) - return (1); - } - - return (0); -} - -/* - * rcsparse_free() - * - * Free the contents of the 's parser data structure. - */ -void -rcsparse_free(RCSFILE *rfp) -{ - struct rcs_pdata *pdp; - - pdp = rfp->rf_pdata; - - if (pdp->rp_buf != NULL) - xfree(pdp->rp_buf); - if (pdp->rp_token == RCS_TYPE_REVISION) - rcsnum_free(pdp->rp_value.rev); - xfree(pdp); -} - -/* - * rcsparse_desc() - * - * Parse desc of the RCS file . By calling rcsparse_desc, all deltas - * will be parsed in order to proceed the reading cursor to the desc keyword. - * - * desc @[...]@; - * - * Returns 0 on success or 1 on error. - */ -static int -rcsparse_desc(RCSFILE *rfp) -{ - struct rcs_pdata *pdp; - - if (rfp->rf_flags & PARSED_DESC) - return (0); - - if (!(rfp->rf_flags & PARSED_DELTAS) && rcsparse_deltas(rfp, NULL)) - return (1); - - pdp = (struct rcs_pdata *)rfp->rf_pdata; - - if (rcsparse_token(rfp, RCS_TOK_DESC) != RCS_TOK_DESC || - rcsparse_token(rfp, RCS_TYPE_STRING) != RCS_TYPE_STRING) - return (1); - - rfp->rf_desc = pdp->rp_value.str; - rfp->rf_flags |= PARSED_DESC; - - return (0); -} - -/* - * rcsparse_deltarevision() - * - * Called upon reaching a new REVISION entry in the delta section. - * A new rcs_delta structure will be prepared in pdp->rp_delta for further - * parsing. - * - * REVISION - * - * Always returns 0. - */ -static int -rcsparse_deltarevision(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - struct rcs_delta *rdp; - - rdp = xcalloc(1, sizeof(*rdp)); - TAILQ_INIT(&rdp->rd_branches); - rdp->rd_num = pdp->rp_value.rev; - pdp->rp_delta = rdp; - - return (0); -} - -/* - * rcsparse_date() - * - * Parses the specified date of current delta pdp->rp_delta. - * - * date YYYY.MM.DD.HH.MM.SS; - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_date(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - if (rcsparse_token(rfp, RCS_TYPE_DATE) != RCS_TYPE_DATE) - return (1); - - pdp->rp_delta->rd_date = pdp->rp_value.date; - - return (rcsparse_token(rfp, RCS_TOK_SCOLON) != RCS_TOK_SCOLON); -} - -/* - * rcsparse_author() - * - * Parses the specified author of current delta pdp->rp_delta. - * - * author LOGIN; - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_author(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - if (rcsparse_token(rfp, RCS_TYPE_LOGIN) != RCS_TYPE_LOGIN) - return (1); - - pdp->rp_delta->rd_author = pdp->rp_value.str; - - return (rcsparse_token(rfp, RCS_TOK_SCOLON) != RCS_TOK_SCOLON); -} - -/* - * rcsparse_state() - * - * Parses the specified state of current delta pdp->rp_delta. - * - * state STATE; - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_state(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - if (rcsparse_token(rfp, RCS_TYPE_STATE) != RCS_TYPE_STATE) - return (1); - - pdp->rp_delta->rd_state = pdp->rp_value.str; - - return (rcsparse_token(rfp, RCS_TOK_SCOLON) != RCS_TOK_SCOLON); -} - -/* - * rcsparse_branches() - * - * Parses the specified branches of current delta pdp->rp_delta. - * - * branches [REVISION ...]; - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_branches(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - struct rcs_branch *rb; - int type; - - while ((type = rcsparse_token(rfp, RCS_TOK_SCOLON|RCS_TYPE_REVISION)) - == RCS_TYPE_REVISION) { - rb = xmalloc(sizeof(*rb)); - rb->rb_num = pdp->rp_value.rev; - TAILQ_INSERT_TAIL(&(pdp->rp_delta->rd_branches), rb, rb_list); - } - - return (type != RCS_TOK_SCOLON); -} - -/* - * rcsparse_next() - * - * Parses the specified next revision of current delta pdp->rp_delta. - * - * next [REVISION]; - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_next(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - int type; - - type = rcsparse_token(rfp, RCS_TYPE_REVISION|RCS_TOK_SCOLON); - if (type == RCS_TYPE_REVISION) { - pdp->rp_delta->rd_next = pdp->rp_value.rev; - type = rcsparse_token(rfp, RCS_TOK_SCOLON); - } else - pdp->rp_delta->rd_next = rcsnum_alloc(); - - return (type != RCS_TOK_SCOLON); -} - -/* - * rcsparse_commitid() - * - * Parses the specified commit id of current delta pdp->rp_delta. The - * commitid keyword is optional and can be omitted. - * - * [commitid ID;] - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_commitid(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - if (rcsparse_token(rfp, RCS_TYPE_COMMITID) != RCS_TYPE_COMMITID) - return (1); - - pdp->rp_delta->rd_commitid = pdp->rp_value.str; - - return (rcsparse_token(rfp, RCS_TOK_SCOLON) != RCS_TOK_SCOLON); -} - -/* - * rcsparse_textrevision() - * - * Called upon reaching a new REVISION entry in the delta text section. - * pdp->rp_delta will be set to REVISION's delta (created in delta section) - * for further parsing. - * - * REVISION - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_textrevision(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - struct rcs_delta *rdp; - - TAILQ_FOREACH(rdp, &rfp->rf_delta, rd_list) { - if (rcsnum_cmp(rdp->rd_num, pdp->rp_value.rev, 0) == 0) - break; - } - if (rdp == NULL) { - rcsparse_warnx(rfp, "delta for revision \"%s\" not found", - pdp->rp_buf); - rcsnum_free(pdp->rp_value.rev); - return (1); - } - pdp->rp_delta = rdp; - - rcsnum_free(pdp->rp_value.rev); - return (0); -} - -/* - * rcsparse_log() - * - * Parses the specified log of current deltatext pdp->rp_delta. - * - * log @[...]@ - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_log(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - if (rcsparse_token(rfp, RCS_TYPE_STRING) != RCS_TYPE_STRING) - return (1); - - pdp->rp_delta->rd_log = pdp->rp_value.str; - - return (0); -} - -/* - * rcsparse_text() - * - * Parses the specified text of current deltatext pdp->rp_delta. - * - * text @[...]@ - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_text(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - if (rcsparse_token(rfp, RCS_TYPE_STRING) != RCS_TYPE_STRING) - return (1); - - pdp->rp_delta->rd_tlen = pdp->rp_tlen - 1; - if (pdp->rp_delta->rd_tlen == 0) { - pdp->rp_delta->rd_text = xstrdup(""); - } else { - pdp->rp_delta->rd_text = xmalloc(pdp->rp_delta->rd_tlen); - memcpy(pdp->rp_delta->rd_text, pdp->rp_buf, - pdp->rp_delta->rd_tlen); - } - xfree(pdp->rp_value.str); - - return (0); -} - -/* - * rcsparse_head() - * - * Parses the head revision of RCS file . - * - * head [REVISION]; - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_head(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - int type; - - type = rcsparse_token(rfp, RCS_TYPE_REVISION|RCS_TOK_SCOLON); - if (type == RCS_TYPE_REVISION) { - rfp->rf_head = pdp->rp_value.rev; - type = rcsparse_token(rfp, RCS_TOK_SCOLON); - } - - return (type != RCS_TOK_SCOLON); -} - -/* - * rcsparse_branch() - * - * Parses the default branch of RCS file . The branch keyword is - * optional and can be omitted. - * - * [branch BRANCH;] - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_branch(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - int type; - - type = rcsparse_token(rfp, RCS_TYPE_BRANCH|RCS_TOK_SCOLON); - if (type == RCS_TYPE_BRANCH) { - rfp->rf_branch = pdp->rp_value.rev; - type = rcsparse_token(rfp, RCS_TOK_SCOLON); - } - - return (type != RCS_TOK_SCOLON); -} - -/* - * rcsparse_access() - * - * Parses the access list of RCS file . - * - * access [LOGIN ...]; - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_access(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - struct rcs_access *ap; - int type; - - while ((type = rcsparse_token(rfp, RCS_TOK_SCOLON|RCS_TYPE_LOGIN)) - == RCS_TYPE_LOGIN) { - ap = xmalloc(sizeof(*ap)); - ap->ra_name = pdp->rp_value.str; - TAILQ_INSERT_TAIL(&(rfp->rf_access), ap, ra_list); - } - - return (type != RCS_TOK_SCOLON); -} - -/* - * rcsparse_symbols() - * - * Parses the symbol list of RCS file . - * - * symbols [SYMBOL:REVISION ...]; - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_symbols(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - struct rcs_sym *symp; - char *name; - int type; - - while ((type = rcsparse_token(rfp, RCS_TOK_SCOLON|RCS_TYPE_SYMBOL)) == - RCS_TYPE_SYMBOL) { - name = pdp->rp_value.str; - if (rcsparse_token(rfp, RCS_TOK_COLON) != RCS_TOK_COLON || - rcsparse_token(rfp, RCS_TYPE_NUMBER) != RCS_TYPE_NUMBER) { - xfree(name); - return (1); - } - symp = xmalloc(sizeof(*symp)); - symp->rs_name = name; - symp->rs_num = pdp->rp_value.rev; - TAILQ_INSERT_TAIL(&(rfp->rf_symbols), symp, rs_list); - } - - return (type != RCS_TOK_SCOLON); -} - -/* - * rcsparse_locks() - * - * Parses the lock list of RCS file . - * - * locks [SYMBOL:REVISION ...]; - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_locks(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - struct rcs_lock *lkp; - char *name; - int type; - - while ((type = rcsparse_token(rfp, RCS_TOK_SCOLON|RCS_TYPE_LOGIN)) == - RCS_TYPE_LOGIN) { - name = pdp->rp_value.str; - if (rcsparse_token(rfp, RCS_TOK_COLON) != RCS_TOK_COLON || - rcsparse_token(rfp, RCS_TYPE_REVISION) != - RCS_TYPE_REVISION) { - xfree(name); - return (1); - } - lkp = xmalloc(sizeof(*lkp)); - lkp->rl_name = name; - lkp->rl_num = pdp->rp_value.rev; - TAILQ_INSERT_TAIL(&(rfp->rf_locks), lkp, rl_list); - } - - return (type != RCS_TOK_SCOLON); -} - -/* - * rcsparse_locks() - * - * Parses the strict keyword of RCS file . The strict keyword is - * optional and can be omitted. - * - * [strict;] - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_strict(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - rfp->rf_flags |= RCS_SLOCK; - - return (rcsparse_token(rfp, RCS_TOK_SCOLON) != RCS_TOK_SCOLON); -} - -/* - * rcsparse_comment() - * - * Parses the comment of RCS file . The comment keyword is optional - * and can be omitted. - * - * [comment [@[...]@];] - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_comment(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - int type; - - type = rcsparse_token(rfp, RCS_TYPE_STRING|RCS_TOK_SCOLON); - if (type == RCS_TYPE_STRING) { - rfp->rf_comment = pdp->rp_value.str; - type = rcsparse_token(rfp, RCS_TOK_SCOLON); - } - - return (type != RCS_TOK_SCOLON); -} - -/* - * rcsparse_expand() - * - * Parses expand of RCS file . The expand keyword is optional and - * can be omitted. - * - * [expand [@[...]@];] - * - * Returns 0 on success or 1 on failure. - */ -static int -rcsparse_expand(RCSFILE *rfp, struct rcs_pdata *pdp) -{ - int type; - - type = rcsparse_token(rfp, RCS_TYPE_STRING|RCS_TOK_SCOLON); - if (type == RCS_TYPE_STRING) { - rfp->rf_expand = pdp->rp_value.str; - type = rcsparse_token(rfp, RCS_TOK_SCOLON); - } - - return (type != RCS_TOK_SCOLON); -} - -#define RBUF_PUTC(ch) \ -do { \ - if (bp == pdp->rp_bufend - 1) { \ - len = bp - pdp->rp_buf; \ - rcsparse_growbuf(rfp); \ - bp = pdp->rp_buf + len; \ - } \ - *(bp++) = (ch); \ - pdp->rp_tlen++; \ -} while (0); - -static int -rcsparse_string(RCSFILE *rfp, int allowed) -{ - struct rcs_pdata *pdp; - int c; - size_t len; - char *bp; - - pdp = (struct rcs_pdata *)rfp->rf_pdata; - - bp = pdp->rp_buf; - pdp->rp_tlen = 0; - *bp = '\0'; - - for (;;) { - c = getc(rfp->rf_file); - if (c == '@') { - c = getc(rfp->rf_file); - if (c == EOF) { - return (EOF); - } else if (c != '@') { - ungetc(c, rfp->rf_file); - break; - } - } - - if (c == EOF) { - return (EOF); - } else if (c == '\n') - pdp->rp_lineno++; - - RBUF_PUTC(c); - } - - bp = pdp->rp_buf + pdp->rp_tlen; - RBUF_PUTC('\0'); - - if (!(allowed & RCS_TYPE_STRING)) { - rcsparse_warnx(rfp, "unexpected RCS string"); - return (0); - } - - pdp->rp_value.str = xstrdup(pdp->rp_buf); - - return (RCS_TYPE_STRING); -} - -static int -rcsparse_token(RCSFILE *rfp, int allowed) -{ - const struct rcs_keyword *p; - struct rcs_pdata *pdp; - int c, pre, ret, type; - char *bp; - size_t len; - RCSNUM *datenum; - - pdp = (struct rcs_pdata *)rfp->rf_pdata; - - if (pdp->rp_token != -1) { - /* no need to check for allowed here */ - type = pdp->rp_token; - pdp->rp_token = -1; - return (type); - } - - /* skip whitespaces */ - c = EOF; - do { - pre = c; - c = getc(rfp->rf_file); - if (c == EOF) { - if (ferror(rfp->rf_file)) { - rcsparse_warnx(rfp, "error during parsing"); - return (0); - } - if (pre != '\n') - rcsparse_warnx(rfp, - "no newline at end of file"); - return (EOF); - } else if (c == '\n') - pdp->rp_lineno++; - } while (isspace(c)); - - pdp->rp_msglineno = pdp->rp_lineno; - switch (c) { - case '@': - ret = rcsparse_string(rfp, allowed); - if (ret == EOF && ferror(rfp->rf_file)) { - rcsparse_warnx(rfp, "error during parsing"); - return (0); - } - return (ret); - /* NOTREACHED */ - case ':': - type = RCS_TOK_COLON; - if (type & allowed) - return (type); - rcsparse_warnx(rfp, "unexpected token \"%c\"", c); - return (0); - /* NOTREACHED */ - case ';': - type = RCS_TOK_SCOLON; - if (type & allowed) - return (type); - rcsparse_warnx(rfp, "unexpected token \"%c\"", c); - return (0); - /* NOTREACHED */ - case ',': - type = RCS_TOK_COMMA; - if (type & allowed) - return (type); - rcsparse_warnx(rfp, "unexpected token \"%c\"", c); - return (0); - /* NOTREACHED */ - default: - if (!isgraph(c)) { - rcsparse_warnx(rfp, "unexpected character 0x%.2X", c); - return (0); - } - break; - } - allowed &= ~(RCS_TOK_COLON|RCS_TOK_SCOLON|RCS_TOK_COMMA); - - bp = pdp->rp_buf; - pdp->rp_tlen = 0; - *bp = '\0'; - - for (;;) { - if (c == EOF) { - if (ferror(rfp->rf_file)) - rcsparse_warnx(rfp, "error during parsing"); - else - rcsparse_warnx(rfp, "unexpected end of file"); - return (0); - } else if (c == '\n') - pdp->rp_lineno++; - - RBUF_PUTC(c); - - c = getc(rfp->rf_file); - - if (isspace(c)) { - if (c == '\n') - pdp->rp_lineno++; - RBUF_PUTC('\0'); - break; - } else if (c == ';' || c == ':' || c == ',') { - ungetc(c, rfp->rf_file); - RBUF_PUTC('\0'); - break; - } else if (!isgraph(c)) { - rcsparse_warnx(rfp, "unexpected character 0x%.2X", c); - return (0); - } - } - - switch (allowed) { - case RCS_TYPE_COMMITID: - if (!valid_commitid(pdp->rp_buf)) { - rcsparse_warnx(rfp, "invalid commitid \"%s\"", - pdp->rp_buf); - return (0); - } - pdp->rp_value.str = xstrdup(pdp->rp_buf); - break; - case RCS_TYPE_LOGIN: - if (!valid_login(pdp->rp_buf)) { - rcsparse_warnx(rfp, "invalid login \"%s\"", - pdp->rp_buf); - return (0); - } - pdp->rp_value.str = xstrdup(pdp->rp_buf); - break; - case RCS_TYPE_SYMBOL: - if (!rcs_sym_check(pdp->rp_buf)) { - rcsparse_warnx(rfp, "invalid symbol \"%s\"", - pdp->rp_buf); - return (0); - } - pdp->rp_value.str = xstrdup(pdp->rp_buf); - break; - /* FALLTHROUGH */ - case RCS_TYPE_STATE: - if (rcs_state_check(pdp->rp_buf)) { - rcsparse_warnx(rfp, "invalid state \"%s\"", - pdp->rp_buf); - return (0); - } - pdp->rp_value.str = xstrdup(pdp->rp_buf); - break; - case RCS_TYPE_DATE: - if ((datenum = rcsnum_parse(pdp->rp_buf)) == NULL) { - rcsparse_warnx(rfp, "invalid date \"%s\"", pdp->rp_buf); - return (0); - } - if (datenum->rn_len != 6) { - rcsnum_free(datenum); - rcsparse_warnx(rfp, "invalid date \"%s\"", pdp->rp_buf); - return (0); - } - pdp->rp_value.date.tm_year = datenum->rn_id[0]; - if (pdp->rp_value.date.tm_year >= 1900) - pdp->rp_value.date.tm_year -= 1900; - pdp->rp_value.date.tm_mon = datenum->rn_id[1] - 1; - pdp->rp_value.date.tm_mday = datenum->rn_id[2]; - pdp->rp_value.date.tm_hour = datenum->rn_id[3]; - pdp->rp_value.date.tm_min = datenum->rn_id[4]; - pdp->rp_value.date.tm_sec = datenum->rn_id[5]; - rcsnum_free(datenum); - break; - case RCS_TYPE_NUMBER: - pdp->rp_value.rev = rcsnum_parse(pdp->rp_buf); - if (pdp->rp_value.rev == NULL) { - rcsparse_warnx(rfp, "invalid number \"%s\"", - pdp->rp_buf); - return (0); - } - break; - case RCS_TYPE_BRANCH: - pdp->rp_value.rev = rcsnum_parse(pdp->rp_buf); - if (pdp->rp_value.rev == NULL) { - rcsparse_warnx(rfp, "invalid branch \"%s\"", - pdp->rp_buf); - return (0); - } - if (!RCSNUM_ISBRANCH(pdp->rp_value.rev)) { - rcsnum_free(pdp->rp_value.rev); - rcsparse_warnx(rfp, "expected branch, got \"%s\"", - pdp->rp_buf); - return (0); - } - break; - case RCS_TYPE_KEYWORD: - if (islower(*pdp->rp_buf)) { - p = bsearch(pdp->rp_buf, keywords, - sizeof(keywords) / sizeof(keywords[0]), - sizeof(keywords[0]), kw_cmp); - if (p != NULL) - return (p->k_val); - } - allowed = RCS_TYPE_REVISION; - /* FALLTHROUGH */ - case RCS_TYPE_REVISION: - pdp->rp_value.rev = rcsnum_parse(pdp->rp_buf); - if (pdp->rp_value.rev != NULL) { - if (RCSNUM_ISBRANCH(pdp->rp_value.rev)) { - rcsnum_free(pdp->rp_value.rev); - rcsparse_warnx(rfp, - "expected revision, got \"%s\"", - pdp->rp_buf); - return (0); - } - break; - } - /* FALLTHROUGH */ - default: - RBUF_PUTC('\0'); - rcsparse_warnx(rfp, "unexpected token \"%s\"", pdp->rp_buf); - return (0); - /* NOTREACHED */ - } - - return (allowed); -} - -static int -rcsparse(RCSFILE *rfp, struct rcs_section *sec) -{ - struct rcs_pdata *pdp; - int i, token; - - pdp = (struct rcs_pdata *)rfp->rf_pdata; - - token = 0; - for (i = 0; sec[i].token != 0; i++) { - token = rcsparse_token(rfp, RCS_TYPE_KEYWORD); - if (token == 0) - return (1); - - while (token != sec[i].token) { - if (sec[i].parse == NULL) - goto end; - if (sec[i].opt) { - i++; - continue; - } - if (token == EOF || (!(rfp->rf_flags & PARSED_DELTAS) && - token == RCS_TOK_DESC)) - goto end; - rcsparse_warnx(rfp, "unexpected token \"%s\"", - pdp->rp_buf); - return (1); - } - - if (sec[i].parse(rfp, pdp)) - return (1); - } -end: - if (token == RCS_TYPE_REVISION) - pdp->rp_token = token; - else if (token == RCS_TOK_DESC) - pdp->rp_token = RCS_TOK_DESC; - else if (token == EOF) - rfp->rf_flags |= RCS_PARSED; - - return (0); -} - -static int -rcsparse_deltatext(RCSFILE *rfp) -{ - int ret; - - if (rfp->rf_flags & PARSED_DELTATEXTS) - return (0); - - if (!(rfp->rf_flags & PARSED_DESC)) - if ((ret = rcsparse_desc(rfp))) - return (ret); - - if (rcsparse(rfp, sec_deltatext)) - return (-1); - - if (rfp->rf_flags & RCS_PARSED) - rfp->rf_flags |= PARSED_DELTATEXTS; - - return (1); -} - -static int -rcsparse_delta(RCSFILE *rfp) -{ - struct rcs_pdata *pdp; - - if (rfp->rf_flags & PARSED_DELTAS) - return (0); - - pdp = (struct rcs_pdata *)rfp->rf_pdata; - if (pdp->rp_token == RCS_TOK_DESC) { - rfp->rf_flags |= PARSED_DELTAS; - return (0); - } - - if (rcsparse(rfp, sec_delta)) - return (-1); - - if (pdp->rp_delta != NULL) { - TAILQ_INSERT_TAIL(&rfp->rf_delta, pdp->rp_delta, rd_list); - pdp->rp_delta = NULL; - rfp->rf_ndelta++; - return (1); - } - - return (0); -} - -/* - * rcsparse_growbuf() - * - * Attempt to grow the internal parse buffer for the RCS file by - * RCS_BUFEXTSIZE. - * In case of failure, the original buffer is left unmodified. - */ -static void -rcsparse_growbuf(RCSFILE *rfp) -{ - struct rcs_pdata *pdp = (struct rcs_pdata *)rfp->rf_pdata; - - pdp->rp_buf = xreallocarray(pdp->rp_buf, 1, - pdp->rp_blen + RCS_BUFEXTSIZE); - pdp->rp_blen += RCS_BUFEXTSIZE; - pdp->rp_bufend = pdp->rp_buf + pdp->rp_blen - 1; -} - -/* - * Borrowed from src/usr.sbin/user/user.c: - * return 1 if `login' is a valid login name - */ -static int -valid_login(char *login_name) -{ - unsigned char *cp; - - /* The first character cannot be a hyphen */ - if (*login_name == '-') - return 0; - - for (cp = login_name ; *cp ; cp++) { - /* We allow '$' as the last character for samba */ - if (!isalnum(*cp) && *cp != '.' && *cp != '_' && *cp != '-' && - !(*cp == '$' && *(cp + 1) == '\0')) { - return 0; - } - } - if ((char *)cp - login_name > _PW_NAME_LEN) - return 0; - return 1; -} - -static int -valid_commitid(char *commitid) -{ - unsigned char *cp; - - /* A-Za-z0-9 */ - for (cp = commitid; *cp ; cp++) { - if (!isalnum(*cp)) - return 0; - } - if ((char *)cp - commitid > RCS_COMMITID_MAXLEN) - return 0; - return 1; -} - -static int -kw_cmp(const void *k, const void *e) -{ - return (strcmp(k, ((const struct rcs_keyword *)e)->k_name)); -} - -static void -rcsparse_warnx(RCSFILE *rfp, char *fmt, ...) -{ - struct rcs_pdata *pdp; - va_list ap; - char *msg; - - pdp = (struct rcs_pdata *)rfp->rf_pdata; - va_start(ap, fmt); - if (vasprintf(&msg, fmt, ap) == -1) { - warn("vasprintf"); - va_end(ap); - return; - } - va_end(ap); - warnx("%s:%d: %s", rfp->rf_path, pdp->rp_msglineno, msg); - free(msg); -} Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/rcsparse.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/rcsutil.c =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/rcsutil.c (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/rcsutil.c (nonexistent) @@ -1,634 +0,0 @@ -/* $OpenBSD: rcsutil.c,v 1.43 2015/01/16 06:40:11 deraadt Exp $ */ -/* - * Copyright (c) 2005, 2006 Joris Vink - * Copyright (c) 2006 Xavier Santolaria - * Copyright (c) 2006 Niall O'Higgins - * Copyright (c) 2006 Ray Lai - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "rcsprog.h" - -/* - * rcs_get_mtime() - * - * Get last modified time. - * Returns last modified time on success, or -1 on failure. - */ -time_t -rcs_get_mtime(RCSFILE *file) -{ - struct stat st; - time_t mtime; - - if (file->rf_file == NULL) - return (-1); - - if (fstat(fileno(file->rf_file), &st) == -1) { - warn("%s", file->rf_path); - return (-1); - } - - mtime = st.st_mtimespec.tv_sec; - - return (mtime); -} - -/* - * rcs_set_mtime() - * - * Set last modified time to if it's not set to -1. - */ -void -rcs_set_mtime(RCSFILE *file, time_t mtime) -{ - static struct timeval tv[2]; - - if (file->rf_file == NULL || mtime == -1) - return; - - tv[0].tv_sec = mtime; - tv[1].tv_sec = tv[0].tv_sec; - - if (futimes(fileno(file->rf_file), tv) == -1) - err(1, "utimes"); -} - -int -rcs_getopt(int argc, char **argv, const char *optstr) -{ - char *a; - const char *c; - static int i = 1; - int opt, hasargument, ret; - - hasargument = 0; - rcs_optarg = NULL; - - if (i >= argc) - return (-1); - - a = argv[i++]; - if (*a++ != '-') - return (-1); - - ret = 0; - opt = *a; - for (c = optstr; *c != '\0'; c++) { - if (*c == opt) { - a++; - ret = opt; - - if (*(c + 1) == ':') { - if (*(c + 2) == ':') { - if (*a != '\0') - hasargument = 1; - } else { - if (*a != '\0') { - hasargument = 1; - } else { - ret = 1; - break; - } - } - } - - if (hasargument == 1) - rcs_optarg = a; - - if (ret == opt) - rcs_optind++; - break; - } - } - - if (ret == 0) - warnx("unknown option -%c", opt); - else if (ret == 1) - warnx("missing argument for option -%c", opt); - - return (ret); -} - -/* - * rcs_choosefile() - * - * Given a relative filename, decide where the corresponding RCS file - * should be. Tries each extension until a file is found. If no file - * was found, returns a path with the first extension. - * - * Opens and returns file descriptor to RCS file. - */ -int -rcs_choosefile(const char *filename, char *out, size_t len) -{ - int fd; - struct stat sb; - char *p, *ext, name[PATH_MAX], *next, *ptr, rcsdir[PATH_MAX], - *suffixes, rcspath[PATH_MAX]; - - /* - * If `filename' contains a directory, `rcspath' contains that - * directory, including a trailing slash. Otherwise `rcspath' - * contains an empty string. - */ - if (strlcpy(rcspath, filename, sizeof(rcspath)) >= sizeof(rcspath)) - errx(1, "rcs_choosefile: truncation"); - - /* If `/' is found, end string after `/'. */ - if ((ptr = strrchr(rcspath, '/')) != NULL) - *(++ptr) = '\0'; - else - rcspath[0] = '\0'; - - /* Append RCS/ to `rcspath' if it exists. */ - if (strlcpy(rcsdir, rcspath, sizeof(rcsdir)) >= sizeof(rcsdir) || - strlcat(rcsdir, RCSDIR, sizeof(rcsdir)) >= sizeof(rcsdir)) - errx(1, "rcs_choosefile: truncation"); - - if (stat(rcsdir, &sb) == 0 && S_ISDIR(sb.st_mode)) - if (strlcpy(rcspath, rcsdir, sizeof(rcspath)) - >= sizeof(rcspath) || - strlcat(rcspath, "/", sizeof(rcspath)) >= sizeof(rcspath)) - errx(1, "rcs_choosefile: truncation"); - - /* Name of file without path. */ - if ((ptr = strrchr(filename, '/')) == NULL) { - if (strlcpy(name, filename, sizeof(name)) >= sizeof(name)) - errx(1, "rcs_choosefile: truncation"); - } else { - /* Skip `/'. */ - if (strlcpy(name, ptr + 1, sizeof(name)) >= sizeof(name)) - errx(1, "rcs_choosefile: truncation"); - } - - /* Name of RCS file without an extension. */ - if (strlcat(rcspath, name, sizeof(rcspath)) >= sizeof(rcspath)) - errx(1, "rcs_choosefile: truncation"); - - /* - * If only the empty suffix was given, use existing rcspath. - * This ensures that there is at least one suffix for strsep(). - */ - if (strcmp(rcs_suffixes, "") == 0) { - if (strlcpy(out, rcspath, len) >= len) - errx(1, "rcs_choosefile: truncation"); - fd = open(rcspath, O_RDONLY); - return (fd); - } - - /* - * Cycle through slash-separated `rcs_suffixes', appending each - * extension to `rcspath' and testing if the file exists. If it - * does, return that string. Otherwise return path with first - * extension. - */ - suffixes = xstrdup(rcs_suffixes); - for (next = suffixes; (ext = strsep(&next, "/")) != NULL;) { - char fpath[PATH_MAX]; - - if ((p = strrchr(rcspath, ',')) != NULL) { - if (!strcmp(p, ext)) { - if ((fd = open(rcspath, O_RDONLY)) == -1) - continue; - - if (fstat(fd, &sb) == -1) - err(1, "%s", rcspath); - - if (strlcpy(out, rcspath, len) >= len) - errx(1, "rcs_choosefile; truncation"); - - xfree(suffixes); - return (fd); - } - - continue; - } - - /* Construct RCS file path. */ - if (strlcpy(fpath, rcspath, sizeof(fpath)) >= sizeof(fpath) || - strlcat(fpath, ext, sizeof(fpath)) >= sizeof(fpath)) - errx(1, "rcs_choosefile: truncation"); - - /* Don't use `filename' as RCS file. */ - if (strcmp(fpath, filename) == 0) - continue; - - if ((fd = open(fpath, O_RDONLY)) == -1) - continue; - - if (fstat(fd, &sb) == -1) - err(1, "%s", fpath); - - if (strlcpy(out, fpath, len) >= len) - errx(1, "rcs_choosefile: truncation"); - - xfree(suffixes); - return (fd); - } - - /* - * `suffixes' should now be NUL separated, so the first - * extension can be read just by reading `suffixes'. - */ - if (strlcat(rcspath, suffixes, sizeof(rcspath)) >= sizeof(rcspath)) - errx(1, "rcs_choosefile: truncation"); - - xfree(suffixes); - - if (strlcpy(out, rcspath, len) >= len) - errx(1, "rcs_choosefile: truncation"); - - fd = open(rcspath, O_RDONLY); - - return (fd); -} - -/* - * Set to . Print warning if is redefined. - */ -void -rcs_setrevstr(char **str, char *new_str) -{ - if (new_str == NULL) - return; - if (*str != NULL) - warnx("redefinition of revision number"); - *str = new_str; -} - -/* - * Set or to , depending on which is not set. - * If both are set, error out. - */ -void -rcs_setrevstr2(char **str1, char **str2, char *new_str) -{ - if (new_str == NULL) - return; - if (*str1 == NULL) - *str1 = new_str; - else if (*str2 == NULL) - *str2 = new_str; - else - errx(1, "too many revision numbers"); -} - -/* - * Get revision from file. The revision can be specified as a symbol or - * a revision number. - */ -RCSNUM * -rcs_getrevnum(const char *rev_str, RCSFILE *file) -{ - RCSNUM *rev; - - /* Search for symbol. */ - rev = rcs_sym_getrev(file, rev_str); - - /* Search for revision number. */ - if (rev == NULL) - rev = rcsnum_parse(rev_str); - - return (rev); -} - -/* - * Prompt for and store user's input in an allocated string. - * - * Returns the string's pointer. - */ -char * -rcs_prompt(const char *prompt) -{ - BUF *bp; - size_t len; - char *buf; - - bp = buf_alloc(0); - if (isatty(STDIN_FILENO)) - (void)fprintf(stderr, "%s", prompt); - if (isatty(STDIN_FILENO)) - (void)fprintf(stderr, ">> "); - clearerr(stdin); - while ((buf = fgetln(stdin, &len)) != NULL) { - /* The last line may not be EOL terminated. */ - if (buf[0] == '.' && (len == 1 || buf[1] == '\n')) - break; - else - buf_append(bp, buf, len); - - if (isatty(STDIN_FILENO)) - (void)fprintf(stderr, ">> "); - } - buf_putc(bp, '\0'); - - return (buf_release(bp)); -} - -u_int -rcs_rev_select(RCSFILE *file, const char *range) -{ - int i; - u_int nrev; - char *ep; - char *lstr, *rstr; - struct rcs_delta *rdp; - struct rcs_argvector *revargv, *revrange; - RCSNUM lnum, rnum; - - nrev = 0; - (void)memset(&lnum, 0, sizeof(lnum)); - (void)memset(&rnum, 0, sizeof(rnum)); - - if (range == NULL) { - TAILQ_FOREACH(rdp, &file->rf_delta, rd_list) - if (rcsnum_cmp(rdp->rd_num, file->rf_head, 0) == 0) { - rdp->rd_flags |= RCS_RD_SELECT; - return (1); - } - return (0); - } - - revargv = rcs_strsplit(range, ","); - for (i = 0; revargv->argv[i] != NULL; i++) { - revrange = rcs_strsplit(revargv->argv[i], ":"); - if (revrange->argv[0] == NULL) - /* should not happen */ - errx(1, "invalid revision range: %s", revargv->argv[i]); - else if (revrange->argv[1] == NULL) - lstr = rstr = revrange->argv[0]; - else { - if (revrange->argv[2] != NULL) - errx(1, "invalid revision range: %s", - revargv->argv[i]); - lstr = revrange->argv[0]; - rstr = revrange->argv[1]; - if (strcmp(lstr, "") == 0) - lstr = NULL; - if (strcmp(rstr, "") == 0) - rstr = NULL; - } - - if (lstr == NULL) - lstr = RCS_HEAD_INIT; - if (rcsnum_aton(lstr, &ep, &lnum) == 0 || (*ep != '\0')) - errx(1, "invalid revision: %s", lstr); - - if (rstr != NULL) { - if (rcsnum_aton(rstr, &ep, &rnum) == 0 || (*ep != '\0')) - errx(1, "invalid revision: %s", rstr); - } else - rcsnum_cpy(file->rf_head, &rnum, 0); - - rcs_argv_destroy(revrange); - - TAILQ_FOREACH(rdp, &file->rf_delta, rd_list) - if (rcsnum_cmp(rdp->rd_num, &lnum, 0) <= 0 && - rcsnum_cmp(rdp->rd_num, &rnum, 0) >= 0 && - !(rdp->rd_flags & RCS_RD_SELECT)) { - rdp->rd_flags |= RCS_RD_SELECT; - nrev++; - } - } - rcs_argv_destroy(revargv); - - if (lnum.rn_id != NULL) - xfree(lnum.rn_id); - if (rnum.rn_id != NULL) - xfree(rnum.rn_id); - - return (nrev); -} - -/* - * Load description from to . - * If starts with a `-', is taken as the description. - * Otherwise is the name of the file containing the description. - * If is NULL, the description is read from stdin. - * Returns 0 on success, -1 on failure, setting errno. - */ -int -rcs_set_description(RCSFILE *file, const char *in) -{ - BUF *bp; - char *content; - const char *prompt = - "enter description, terminated with single '.' or end of file:\n" - "NOTE: This is NOT the log message!\n"; - - /* Description is in file . */ - if (in != NULL && *in != '-') { - if ((bp = buf_load(in)) == NULL) - return (-1); - buf_putc(bp, '\0'); - content = buf_release(bp); - /* Description is in . */ - } else if (in != NULL) - /* Skip leading `-'. */ - content = xstrdup(in + 1); - /* Get description from stdin. */ - else - content = rcs_prompt(prompt); - - rcs_desc_set(file, content); - xfree(content); - return (0); -} - -/* - * Split the contents of a file into a list of lines. - */ -struct rcs_lines * -rcs_splitlines(u_char *data, size_t len) -{ - u_char *c, *p; - struct rcs_lines *lines; - struct rcs_line *lp; - size_t i, tlen; - - lines = xcalloc(1, sizeof(*lines)); - TAILQ_INIT(&(lines->l_lines)); - - lp = xcalloc(1, sizeof(*lp)); - TAILQ_INSERT_TAIL(&(lines->l_lines), lp, l_list); - - - p = c = data; - for (i = 0; i < len; i++) { - if (*p == '\n' || (i == len - 1)) { - tlen = p - c + 1; - lp = xmalloc(sizeof(*lp)); - lp->l_line = c; - lp->l_len = tlen; - lp->l_lineno = ++(lines->l_nblines); - TAILQ_INSERT_TAIL(&(lines->l_lines), lp, l_list); - c = p + 1; - } - p++; - } - - return (lines); -} - -void -rcs_freelines(struct rcs_lines *lines) -{ - struct rcs_line *lp; - - while ((lp = TAILQ_FIRST(&(lines->l_lines))) != NULL) { - TAILQ_REMOVE(&(lines->l_lines), lp, l_list); - xfree(lp); - } - - xfree(lines); -} - -BUF * -rcs_patchfile(u_char *data, size_t dlen, u_char *patch, size_t plen, - int (*p)(struct rcs_lines *, struct rcs_lines *)) -{ - struct rcs_lines *dlines, *plines; - struct rcs_line *lp; - BUF *res; - - dlines = rcs_splitlines(data, dlen); - plines = rcs_splitlines(patch, plen); - - if (p(dlines, plines) < 0) { - rcs_freelines(dlines); - rcs_freelines(plines); - return (NULL); - } - - res = buf_alloc(1024); - TAILQ_FOREACH(lp, &dlines->l_lines, l_list) { - if (lp->l_line == NULL) - continue; - buf_append(res, lp->l_line, lp->l_len); - } - - rcs_freelines(dlines); - rcs_freelines(plines); - return (res); -} - -/* - * rcs_yesno() - * - * Read a char from standard input, returns defc if the - * user enters an equivalent to defc, else whatever char - * was entered. Converts input to lower case. - */ -int -rcs_yesno(int defc) -{ - int c, ret; - - fflush(stderr); - fflush(stdout); - - clearerr(stdin); - if (isalpha(c = getchar())) - c = tolower(c); - if (c == defc || c == '\n' || (c == EOF && feof(stdin))) - ret = defc; - else - ret = c; - - while (c != EOF && c != '\n') - c = getchar(); - - return (ret); -} - -/* - * rcs_strsplit() - * - * Split a string of -separated values and allocate - * an argument vector for the values found. - */ -struct rcs_argvector * -rcs_strsplit(const char *str, const char *sep) -{ - struct rcs_argvector *av; - size_t i = 0; - char *cp, *p; - - cp = xstrdup(str); - av = xmalloc(sizeof(*av)); - av->str = cp; - av->argv = xmalloc(sizeof(*(av->argv))); - - while ((p = strsep(&cp, sep)) != NULL) { - av->argv[i++] = p; - av->argv = xreallocarray(av->argv, - i + 1, sizeof(*(av->argv))); - } - av->argv[i] = NULL; - - return (av); -} - -/* - * rcs_argv_destroy() - * - * Free an argument vector previously allocated by rcs_strsplit(). - */ -void -rcs_argv_destroy(struct rcs_argvector *av) -{ - xfree(av->str); - xfree(av->argv); - xfree(av); -} - -/* - * Strip suffix from filename. - */ -void -rcs_strip_suffix(char *filename) -{ - char *p, *suffixes, *next, *ext; - - if ((p = strrchr(filename, ',')) != NULL) { - suffixes = xstrdup(rcs_suffixes); - for (next = suffixes; (ext = strsep(&next, "/")) != NULL;) { - if (!strcmp(p, ext)) { - *p = '\0'; - break; - } - } - xfree(suffixes); - } -} Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/rcsutil.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/rcsdiff.1 =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/rcsdiff.1 (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/rcsdiff.1 (nonexistent) @@ -1,147 +0,0 @@ -.\" $OpenBSD: rcsdiff.1,v 1.30 2010/09/03 11:09:29 jmc Exp $ -.\" -.\" Copyright (c) 2005 Joris Vink -.\" All rights reserved. -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.Dd $Mdocdate: September 3 2010 $ -.Dt RCSDIFF 1 -.Os -.Sh NAME -.Nm rcsdiff -.Nd compare RCS revisions -.Sh SYNOPSIS -.Nm -.Op Fl cnquV -.Op Fl k Ns Ar mode -.Op Fl r Ns Ar rev -.Op Fl x Ns Ar suffixes -.Op Fl z Ns Ar tz -.Op Ar diff_options -.Ar -.Sh DESCRIPTION -The -.Nm -program is used to compare revisions of RCS files, -in much the same way as the -.Xr diff 1 -utility. -Differences between two specific revisions can be requested, -as well as differences between the current working file and -the latest revision of the default branch. -.Pp -It is not possible to display differences between entire directories, -or differences between more than two files. -All diffs produced are in the standard diff format, -unless the -.Fl u -option is specified, -which produces unified diffs. -.Pp -.Nm -also supports -keyword substitution \(en -see the -.Xr rcs 1 -man page for more information. -.Pp -The following options are supported: -.Bl -tag -width Ds -.It Fl c -Produces a diff with three lines of context. -See -.Xr diff 1 -for more information. -.It Fl k Ns Ar mode -Specify the keyword substitution mode. -.It Fl n -Produces a diff in the same format that is used in the RCS files. -.It Fl q -Be quiet about reporting. -.It Fl r Ns Ar rev -Produces a diff with respect to revision -.Ar rev . -This option should be specified twice to generate a diff -between two specific revisions. -If only one revision is specified, -diffing is done between that revision and -the current working file. -.It Fl u -Produces a unified diff with three lines of context. -See -.Xr diff 1 -for more information. -.It Fl V -Print RCS's version number. -.It Fl x Ns Ar suffixes -Specifies the suffixes for RCS files. -Suffixes should be separated by the -.Sq / -character. -.It Fl z Ns Ar tz -Specify the date output format. -.It Ar diff_options -Most of the options documented in -.Xr diff 1 -may also be specified. -.El -.Sh ENVIRONMENT -.Bl -tag -width RCSINIT -.It Ev RCSINIT -If set, this variable should contain a list of space-delimited options that -are prepended to the argument list. -.It Ev TMPDIR -When set, this variable specifies the directory where temporary files -are to be created. -The default is set to -.Pa /tmp . -.El -.Sh EXIT STATUS -The -.Nm -utility exits with one of the following values: -.Pp -.Bl -tag -width Ds -offset indent -compact -.It 0 -No differences were found. -.It 1 -Differences were found. -.It 2 -An error occurred. -.El -.Sh EXAMPLES -Compare the latest revision of the default branch with the content of -working file -.Pa foo.c : -.Pp -.Dl $ rcsdiff foo.c -.Pp -Compare revision 1.7 and 1.8 of file -.Pa foo.c -and ignore differences in keyword values: -.Pp -.Dl $ rcsdiff -kk -r1.7 -r1.8 foo.c -.Sh SEE ALSO -.Xr ci 1 , -.Xr co 1 , -.Xr diff 1 , -.Xr ident 1 , -.Xr rcs 1 , -.Xr rcsclean 1 , -.Xr rcsmerge 1 , -.Xr rlog 1 -.Sh STANDARDS -The flag -.Op Fl T -has no effect and is provided -for compatibility only. Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/rcsdiff.1 ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/rcsclean.c =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/rcsclean.c (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/rcsclean.c (nonexistent) @@ -1,218 +0,0 @@ -/* $OpenBSD: rcsclean.c,v 1.54 2015/01/16 06:40:11 deraadt Exp $ */ -/* - * Copyright (c) 2005 Joris Vink - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include -#include -#include -#include -#include - -#include "rcsprog.h" -#include "diff.h" - -static void rcsclean_file(char *, const char *); - -static int nflag = 0; -static int kflag = RCS_KWEXP_ERR; -static int uflag = 0; -static int flags = 0; -static char *locker = NULL; - -int -rcsclean_main(int argc, char **argv) -{ - int i, ch; - char *rev_str; - DIR *dirp; - struct dirent *dp; - - rev_str = NULL; - - while ((ch = rcs_getopt(argc, argv, "k:n::q::r::Tu::Vx::")) != -1) { - switch (ch) { - case 'k': - kflag = rcs_kflag_get(rcs_optarg); - if (RCS_KWEXP_INVAL(kflag)) { - warnx("invalid RCS keyword substitution mode"); - (usage)(); - } - break; - case 'n': - rcs_setrevstr(&rev_str, rcs_optarg); - nflag = 1; - break; - case 'q': - rcs_setrevstr(&rev_str, rcs_optarg); - flags |= QUIET; - break; - case 'r': - rcs_setrevstr(&rev_str, rcs_optarg); - break; - case 'T': - flags |= PRESERVETIME; - break; - case 'u': - rcs_setrevstr(&rev_str, rcs_optarg); - uflag = 1; - break; - case 'V': - printf("%s\n", rcs_version); - exit(0); - case 'x': - /* Use blank extension if none given. */ - rcs_suffixes = rcs_optarg ? rcs_optarg : ""; - break; - default: - (usage)(); - } - } - - argc -= rcs_optind; - argv += rcs_optind; - - if ((locker = getlogin()) == NULL) - err(1, "getlogin"); - - if (argc == 0) { - if ((dirp = opendir(".")) == NULL) { - warn("opendir"); - (usage)(); - } - - while ((dp = readdir(dirp)) != NULL) { - if (dp->d_type == DT_DIR) - continue; - rcsclean_file(dp->d_name, rev_str); - } - - (void)closedir(dirp); - } else - for (i = 0; i < argc; i++) - rcsclean_file(argv[i], rev_str); - - return (0); -} - -__dead void -rcsclean_usage(void) -{ - fprintf(stderr, - "usage: rcsclean [-TV] [-kmode] [-n[rev]] [-q[rev]] [-r[rev]]\n" - " [-u[rev]] [-xsuffixes] [-ztz] [file ...]\n"); - - exit(1); -} - -static void -rcsclean_file(char *fname, const char *rev_str) -{ - int fd, match; - RCSFILE *file; - char fpath[PATH_MAX], numb[RCS_REV_BUFSZ]; - RCSNUM *rev; - BUF *b1, *b2; - time_t rcs_mtime = -1; - - b1 = b2 = NULL; - file = NULL; - rev = NULL; - - if ((fd = rcs_choosefile(fname, fpath, sizeof(fpath))) < 0) - goto out; - - if ((file = rcs_open(fpath, fd, RCS_RDWR)) == NULL) - goto out; - - if (flags & PRESERVETIME) - rcs_mtime = rcs_get_mtime(file); - - rcs_kwexp_set(file, kflag); - - if (rev_str == NULL) - rev = file->rf_head; - else if ((rev = rcs_getrevnum(rev_str, file)) == NULL) { - warnx("%s: Symbolic name `%s' is undefined.", fpath, rev_str); - goto out; - } - - if ((b1 = rcs_getrev(file, rev)) == NULL) { - warnx("failed to get needed revision"); - goto out; - } - if ((b2 = buf_load(fname)) == NULL) { - warnx("failed to load `%s'", fname); - goto out; - } - - /* If buffer lengths are the same, compare contents as well. */ - if (buf_len(b1) != buf_len(b2)) - match = 0; - else { - size_t len, n; - - len = buf_len(b1); - - match = 1; - for (n = 0; n < len; ++n) - if (buf_getc(b1, n) != buf_getc(b2, n)) { - match = 0; - break; - } - } - - if (match == 1) { - if (uflag == 1 && !TAILQ_EMPTY(&(file->rf_locks))) { - if (!(flags & QUIET) && nflag == 0) { - printf("rcs -u%s %s\n", - rcsnum_tostr(rev, numb, sizeof(numb)), - fpath); - } - (void)rcs_lock_remove(file, locker, rev); - } - - if (TAILQ_EMPTY(&(file->rf_locks))) { - if (!(flags & QUIET)) - printf("rm -f %s\n", fname); - - if (nflag == 0) - (void)unlink(fname); - } - } - - rcs_write(file); - if (flags & PRESERVETIME) - rcs_set_mtime(file, rcs_mtime); - -out: - if (b1 != NULL) - buf_free(b1); - if (b2 != NULL) - buf_free(b2); - if (file != NULL) - rcs_close(file); -} Property changes on: vendor/OpenBSD/dist/usr.bin/rcs/rcsclean.c ___________________________________________________________________ Deleted: svn:eol-style ## -1 +0,0 ## -native \ No newline at end of property Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Deleted: svn:mime-type ## -1 +0,0 ## -text/plain \ No newline at end of property Index: vendor/OpenBSD/dist/usr.bin/rcs/buf.c =================================================================== --- vendor/OpenBSD/dist/usr.bin/rcs/buf.c (revision 358867) +++ vendor/OpenBSD/dist/usr.bin/rcs/buf.c (nonexistent) @@ -1,331 +0,0 @@ -/* $OpenBSD: buf.c,v 1.24 2015/02/05 12:59:58 millert Exp $ */ -/* - * Copyright (c) 2003 Jean-Francois Brousseau - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "buf.h" -#include "xmalloc.h" -#include "worklist.h" - -#define BUF_INCR 128 - -struct buf { - /* buffer handle, buffer size, and data length */ - u_char *cb_buf; - size_t cb_size; - size_t cb_len; -}; - -#define SIZE_LEFT(b) (b->cb_size - b->cb_len) - -static void buf_grow(BUF *, size_t); - -/* - * Create a new buffer structure and return a pointer to it. This structure - * uses dynamically-allocated memory and must be freed with buf_free(), once - * the buffer is no longer needed. - */ -BUF * -buf_alloc(size_t len) -{ - BUF *b; - - b = xmalloc(sizeof(*b)); - /* Postpone creation of zero-sized buffers */ - if (len > 0) - b->cb_buf = xcalloc(1, len); - else - b->cb_buf = NULL; - - b->cb_size = len; - b->cb_len = 0; - - return (b); -} - -/* - * Open the file specified by and load all of its contents into a - * buffer. - * Returns the loaded buffer on success or NULL on failure. - * Sets errno on error. - */ -BUF * -buf_load(const char *path) -{ - int fd; - ssize_t ret; - size_t len; - u_char *bp; - struct stat st; - BUF *buf; - - buf = NULL; - - if ((fd = open(path, O_RDONLY, 0600)) == -1) - goto out; - - if (fstat(fd, &st) == -1) - goto out; - - if (st.st_size > SIZE_MAX) { - errno = EFBIG; - goto out; - } - buf = buf_alloc(st.st_size); - for (bp = buf->cb_buf; ; bp += (size_t)ret) { - len = SIZE_LEFT(buf); - ret = read(fd, bp, len); - if (ret == -1) { - int saved_errno; - - saved_errno = errno; - buf_free(buf); - buf = NULL; - errno = saved_errno; - goto out; - } else if (ret == 0) - break; - - buf->cb_len += (size_t)ret; - } - -out: - if (fd != -1) { - int saved_errno; - - /* We may want to preserve errno here. */ - saved_errno = errno; - (void)close(fd); - errno = saved_errno; - } - - return (buf); -} - -void -buf_free(BUF *b) -{ - if (b->cb_buf != NULL) - xfree(b->cb_buf); - xfree(b); -} - -/* - * Free the buffer 's structural information but do not free the contents - * of the buffer. Instead, they are returned and should be freed later using - * xfree(). - */ -void * -buf_release(BUF *b) -{ - void *tmp; - - tmp = b->cb_buf; - xfree(b); - return (tmp); -} - -u_char * -buf_get(BUF *b) -{ - return (b->cb_buf); -} - -/* - * Empty the contents of the buffer and reset pointers. - */ -void -buf_empty(BUF *b) -{ - memset(b->cb_buf, 0, b->cb_size); - b->cb_len = 0; -} - -/* - * Append a single character to the end of the buffer . - */ -void -buf_putc(BUF *b, int c) -{ - u_char *bp; - - if (SIZE_LEFT(b) == 0) - buf_grow(b, BUF_INCR); - bp = b->cb_buf + b->cb_len; - *bp = (u_char)c; - b->cb_len++; -} - -/* - * Append a string to the end of buffer . - */ -void -buf_puts(BUF *b, const char *str) -{ - buf_append(b, str, strlen(str)); -} - -/* - * Return u_char at buffer position . - */ -u_char -buf_getc(BUF *b, size_t pos) -{ - return (b->cb_buf[pos]); -} - -/* - * Append bytes of data pointed to by to the buffer . If the - * buffer is too small to accept all data, it will get resized to an - * appropriate size to accept all data. - * Returns the number of bytes successfully appended to the buffer. - */ -size_t -buf_append(BUF *b, const void *data, size_t len) -{ - size_t left, rlen; - u_char *bp; - - left = SIZE_LEFT(b); - rlen = len; - - if (left < len) - buf_grow(b, len - left); - bp = b->cb_buf + b->cb_len; - memcpy(bp, data, rlen); - b->cb_len += rlen; - - return (rlen); -} - -/* - * Returns the size of the buffer that is being used. - */ -size_t -buf_len(BUF *b) -{ - return (b->cb_len); -} - -/* - * Write the contents of the buffer to the specified - */ -int -buf_write_fd(BUF *b, int fd) -{ - u_char *bp; - size_t len; - ssize_t ret; - - len = b->cb_len; - bp = b->cb_buf; - - do { - ret = write(fd, bp, len); - if (ret == -1) { - if (errno == EINTR || errno == EAGAIN) - continue; - return (-1); - } - - len -= (size_t)ret; - bp += (size_t)ret; - } while (len > 0); - - return (0); -} - -/* - * Write the contents of the buffer to the file whose path is given in - * . If the file does not exist, it is created with mode . - */ -int -buf_write(BUF *b, const char *path, mode_t mode) -{ - int fd; - open: - if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)) == -1) { - if (errno == EACCES && unlink(path) != -1) - goto open; - else - err(1, "%s", path); - } - - if (buf_write_fd(b, fd) == -1) { - (void)unlink(path); - errx(1, "buf_write: buf_write_fd: `%s'", path); - } - - if (fchmod(fd, mode) < 0) - warn("permissions not set on file %s", path); - - (void)close(fd); - - return (0); -} - -/* - * Write the contents of the buffer to a temporary file whose path is - * specified using