[BACK]Return to patch-fileio.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / pkgsrc / converters / ack / patches

File: [cvs.NetBSD.org] / pkgsrc / converters / ack / patches / patch-fileio.c (download)

Revision 1.2, Sun Jul 6 18:50:20 2014 UTC (6 years, 5 months ago) by dholland
Branch: MAIN
CVS Tags: pkgsrc-2020Q3-base, pkgsrc-2020Q3, pkgsrc-2020Q2-base, pkgsrc-2020Q2, pkgsrc-2020Q1-base, pkgsrc-2020Q1, pkgsrc-2019Q4-base, pkgsrc-2019Q4, pkgsrc-2019Q3-base, pkgsrc-2019Q3, pkgsrc-2019Q2-base, pkgsrc-2019Q2, pkgsrc-2019Q1-base, pkgsrc-2019Q1, pkgsrc-2018Q4-base, pkgsrc-2018Q4, pkgsrc-2018Q3-base, pkgsrc-2018Q3, pkgsrc-2018Q2-base, pkgsrc-2018Q2, pkgsrc-2018Q1-base, pkgsrc-2018Q1, pkgsrc-2017Q4-base, pkgsrc-2017Q4, pkgsrc-2017Q3-base, pkgsrc-2017Q3, pkgsrc-2017Q2-base, pkgsrc-2017Q2, pkgsrc-2017Q1-base, pkgsrc-2017Q1, pkgsrc-2016Q4-base, pkgsrc-2016Q4, pkgsrc-2016Q3-base, pkgsrc-2016Q3, pkgsrc-2016Q2-base, pkgsrc-2016Q2, pkgsrc-2016Q1-base, pkgsrc-2016Q1, pkgsrc-2015Q4-base, pkgsrc-2015Q4, pkgsrc-2015Q3-base, pkgsrc-2015Q3, pkgsrc-2015Q2-base, pkgsrc-2015Q2, pkgsrc-2015Q1-base, pkgsrc-2015Q1, pkgsrc-2014Q4-base, pkgsrc-2014Q4, pkgsrc-2014Q3-base, pkgsrc-2014Q3, HEAD
Changes since 1.1: +10 -8 lines

Include sys/time.h for utimes(). From PR 48965 by SUNAGAWA Keiki.
Also include sys/types.h first as a general precaution, and don't
use <utime.h> any more.

$NetBSD: patch-fileio.c,v 1.2 2014/07/06 18:50:20 dholland Exp $

- use standard headers
- declare own functions
- avoid implicit int
- declare void functions void
- don't truncate time_t
- use size_t for sizes where easy and appropriate
- use a bit of const
- remove wrong usage of utime(3) and use utimes(3)

--- fileio.c.orig	1994-06-12 05:31:00.000000000 +0000
+++ fileio.c
@@ -4,15 +4,20 @@
 /*			oga@dgw.yz.yamagata-u.ac.jp	*/
 /* v1.10  1994 03/19	Ogasawara Hiroyuki		*/
 
+#include	<sys/types.h>
+#include	<sys/time.h>
 #include	<stdio.h>
 
+#include	"kanjicode.h"
+#include	"misc.h"
+
 #define	EMPTY		0
 #define	STACKSIZE	256
 #define	PRESIZE		(1024*16)
 
 static int	cstack[STACKSIZE],
-		*cstackptr= cstack,
-		presize= 0;
+		*cstackptr= cstack;
+static size_t	presize= 0;
 unsigned char	prebuf[PRESIZE],
 		*preptr= prebuf;
 
@@ -36,7 +41,7 @@ unsigned int	code;
 }
 
 int
-getcode()
+getcode(void)
 {
 	if( cstackptr > cstack )
 		return	*--cstackptr;
@@ -48,7 +53,7 @@ getcode()
 }
 
 void
-ungetcode( code )
+ungetcode( int code )
 {
 	*cstackptr++= code;
 }
@@ -62,31 +67,33 @@ void	*cp;
 }
 
 #if HUMAN
-isdir( name )
-char	*name;
+int
+isdir( const char *name )
 {
 	return	CHMOD( name, -1 ) & 0x10;
 }
 #else
 #include	<sys/types.h>
 #include	<sys/stat.h>
-filedate( fn )
+time_t
+filedate( int fn )
 {
 	struct stat	st;
 	fstat( fn, &st );
 	return	st.st_mtime;
 }
 
-filesetdate( name, set )
-char	*name;
+void
+filesetdate( const char *name, time_t set )
 {
-	time_t	tim[2];
-	tim[0]= tim[1]= set;
-	utime( name, tim );
+	struct timeval	tim[2];
+	tim[0].tv_sec = tim[1].tv_sec = set;
+	tim[0].tv_usec = tim[1].tv_usec = 0;
+	utimes( name, tim );
 }
 
-isdir( name )
-char	*name;
+int
+isdir( const char *name )
 {
 	struct stat	st;
 	stat( name, &st );