mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 16:31:02 +03:00
d942f5a88e
Summary: Adds some basic building blocks to build hg using buck. Header files are cleaned up, so they are relative to the project root. Some minor changes to C code are made to remove clang build warnings. Rust dependencies, fb-hgext C/Python dependencies (ex. cstore, mysql-connector), and 3rd-party dependencies like python-lz4 are not built yet. But the built hg binary should be able to run most tests just fine. Reviewed By: wez Differential Revision: D6814686 fbshipit-source-id: 59eefd5a3ad86db2ad1c821ed824c9f1878c93e4
60 lines
2.1 KiB
C
60 lines
2.1 KiB
C
/*
|
|
charencode.h - miscellaneous character encoding
|
|
|
|
This software may be used and distributed according to the terms of
|
|
the GNU General Public License, incorporated herein by reference.
|
|
*/
|
|
|
|
#ifndef _HG_CHARENCODE_H_
|
|
#define _HG_CHARENCODE_H_
|
|
|
|
#include "mercurial/compat.h"
|
|
#include <Python.h>
|
|
|
|
/* This should be kept in sync with normcasespecs in encoding.py. */
|
|
enum normcase_spec {
|
|
NORMCASE_LOWER = -1,
|
|
NORMCASE_UPPER = 1,
|
|
NORMCASE_OTHER = 0
|
|
};
|
|
|
|
PyObject *unhexlify(const char *str, Py_ssize_t len);
|
|
PyObject *isasciistr(PyObject *self, PyObject *args);
|
|
PyObject *asciilower(PyObject *self, PyObject *args);
|
|
PyObject *asciiupper(PyObject *self, PyObject *args);
|
|
PyObject *make_file_foldmap(PyObject *self, PyObject *args);
|
|
PyObject *jsonescapeu8fast(PyObject *self, PyObject *args);
|
|
|
|
static const int8_t hextable[256] = {
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /* 0-9 */
|
|
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* A-F */
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* a-f */
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
|
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
|
};
|
|
|
|
static inline int hexdigit(const char *p, Py_ssize_t off)
|
|
{
|
|
int8_t val = hextable[(unsigned char)p[off]];
|
|
|
|
if (val >= 0) {
|
|
return val;
|
|
}
|
|
|
|
PyErr_SetString(PyExc_ValueError, "input contains non-hex character");
|
|
return 0;
|
|
}
|
|
|
|
#endif /* _HG_CHARENCODE_H_ */
|