File: gnu_helpers.c

package info (click to toggle)
premake 3.7-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 2,148 kB
  • sloc: ansic: 20,490; cs: 15,185; makefile: 332
file content (61 lines) | stat: -rw-r--r-- 1,447 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/**********************************************************************
 * Premake - gnu_helpers.c
 * The GNU makefile target
 *
 * Copyright (c) 2002-2006 Jason Perkins and the Premake project
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License in the file LICENSE.txt for details.
 **********************************************************************/

#include "premake.h"
#include <string.h>


static char buffer[8192];


int gnu_pkgOwnsPath()
{
	int i;

	if (path_compare(prj_get_pkgpath(), prj_get_path()))
		return 0;

	for (i = 0; i < prj_get_numpackages(); ++i)
	{
		if (prj_get_package() != prj_get_package_for(i))
		{
			if (path_compare(prj_get_pkgpath(), prj_get_pkgpath_for(i)))
				return 0;
		}
	}

	return 1;
}


const char* gnu_escapePath(const char* path)
{
	const char* ch = path;
	int i = 0;
	while (*ch)
	{
		if (*ch == ' ')
		{
			buffer[i++] = '\\';
		}
		buffer[i++] = *ch;
		ch++;
	}

	buffer[i] = '\0';
	return buffer;
}