GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/vi/build/../vi/v_zexit.c Lines: 0 9 0.0 %
Date: 2017-11-13 Branches: 0 8 0.0 %

Line Branch Exec Source
1
/*	$OpenBSD: v_zexit.c,v 1.6 2014/11/12 04:28:41 bentley Exp $	*/
2
3
/*-
4
 * Copyright (c) 1992, 1993, 1994
5
 *	The Regents of the University of California.  All rights reserved.
6
 * Copyright (c) 1992, 1993, 1994, 1995, 1996
7
 *	Keith Bostic.  All rights reserved.
8
 *
9
 * See the LICENSE file for redistribution information.
10
 */
11
12
#include "config.h"
13
14
#include <sys/types.h>
15
#include <sys/queue.h>
16
#include <sys/time.h>
17
18
#include <bitstring.h>
19
#include <limits.h>
20
#include <stdio.h>
21
#include <string.h>
22
23
#include "../common/common.h"
24
#include "vi.h"
25
26
/*
27
 * v_zexit -- ZZ
28
 *	Save the file and exit.
29
 *
30
 * PUBLIC: int v_zexit(SCR *, VICMD *);
31
 */
32
int
33
v_zexit(SCR *sp, VICMD *vp)
34
{
35
	/* Write back any modifications. */
36
	if (F_ISSET(sp->ep, F_MODIFIED) &&
37
	    file_write(sp, NULL, NULL, NULL, FS_ALL))
38
		return (1);
39
40
	/* Check to make sure it's not a temporary file. */
41
	if (file_m3(sp, 0))
42
		return (1);
43
44
	/* Check for more files to edit. */
45
	if (ex_ncheck(sp, 0))
46
		return (1);
47
48
	F_SET(sp, SC_EXIT);
49
	return (0);
50
}