<commit_before>// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package sqlite

/*
#include <sqlite3.h>
#include <stdlib.h>

// cgo doesn't support varargs
static inline char *my_mprintf(char *zFormat, char *arg) {
	return sqlite3_mprintf(zFormat, arg);
}
static inline char *my_mprintf2(char *zFormat, char *arg1, char *arg2) {
	return sqlite3_mprintf(zFormat, arg1, arg2);
}
*/
import "C"

import (
	"reflect"
	"unsafe"
)

// Mprintf is like fmt.Printf but implements some additional formatting options
// that are useful for constructing SQL statements.
// (See http://sqlite.org/c3ref/mprintf.html)
func Mprintf(format string, arg string) string {
	zSQL := mPrintf(format, arg)
	defer C.sqlite3_free(unsafe.Pointer(zSQL))
	return C.GoString(zSQL)
}
func mPrintf(format, arg string) *C.char {
	cf := C.CString(format)
	defer C.free(unsafe.Pointer(cf))
	ca := C.CString(arg)
	defer C.free(unsafe.Pointer(ca))
	return C.my_mprintf(cf, ca)
}

// Mprintf2 is like fmt.Printf but implements some additional formatting options
// that are useful for constructing SQL statements.
// (See http://sqlite.org/c3ref/mprintf.html)
func Mprintf2(format string, arg1, arg2 string) string {
	cf := C.CString(format)
	defer C.free(unsafe.Pointer(cf))
	ca1 := C.CString(arg1)
	defer C.free(unsafe.Pointer(ca1))
	ca2 := C.CString(arg2)
	defer C.free(unsafe.Pointer(ca2))
	zSQL := C.my_mprintf2(cf, ca1, ca2)
	defer C.sqlite3_free(unsafe.Pointer(zSQL))
	return C.GoString(zSQL)
}

// Must is a helper that wraps a call to a function returning (bool, os.Error)
// and panics if the error is non-nil.
func Must(b bool, err error) bool {
	if err != nil {
		panic(err)
	}<commit_msg>To do: sqlite3_mprintf and oom.<commit_after>// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package sqlite

/*
#include <sqlite3.h>
#include <stdlib.h>

// cgo doesn't support varargs
static inline char *my_mprintf(char *zFormat, char *arg) {
	return sqlite3_mprintf(zFormat, arg);
}
static inline char *my_mprintf2(char *zFormat, char *arg1, char *arg2) {
	return sqlite3_mprintf(zFormat, arg1, arg2);
}
*/
import "C"

import (
	"reflect"
	"unsafe"
)

// Mprintf is like fmt.Printf but implements some additional formatting options
// that are useful for constructing SQL statements.
// (See http://sqlite.org/c3ref/mprintf.html)
func Mprintf(format string, arg string) string {
	zSQL := mPrintf(format, arg)
	defer C.sqlite3_free(unsafe.Pointer(zSQL))
	return C.GoString(zSQL)
}
func mPrintf(format, arg string) *C.char { // TODO may return nil when no memory...
	cf := C.CString(format)
	defer C.free(unsafe.Pointer(cf))
	ca := C.CString(arg)
	defer C.free(unsafe.Pointer(ca))
	return C.my_mprintf(cf, ca)
}

// Mprintf2 is like fmt.Printf but implements some additional formatting options
// that are useful for constructing SQL statements.
// (See http://sqlite.org/c3ref/mprintf.html)
func Mprintf2(format string, arg1, arg2 string) string {
	cf := C.CString(format)
	defer C.free(unsafe.Pointer(cf))
	ca1 := C.CString(arg1)
	defer C.free(unsafe.Pointer(ca1))
	ca2 := C.CString(arg2)
	defer C.free(unsafe.Pointer(ca2))
	zSQL := C.my_mprintf2(cf, ca1, ca2) // TODO may return nil when no memory...
	defer C.sqlite3_free(unsafe.Pointer(zSQL))
	return C.GoString(zSQL)
}

// Must is a helper that wraps a call to a function returning (bool, os.Error)
// and panics if the error is non-nil.
func Must(b bool, err error) bool {
	if err != nil {
		panic(err)
	}
{'fraction_non_alphanumeric': 0.12609649122807018, 'fraction_numerical': 0.01617324561403509, 'mean_word_length': 4.2277936962750715, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '577325', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1285, 'n_words': 400}