some sources added
This commit is contained in:
parent
dfcf4aa240
commit
07beff8665
|
@ -0,0 +1,48 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
static const gchar *str = "[ds|fs]{|>{\\centering}p{0.11\\linewidth}|>{\\raggedright}p{0.05\\linewidth}|>{\\centering}p{0.07\\paperwidth}|>{\\centering}p{0.07\\paperwidth}|>{\\centering}m{0.07\\paperheight}|>{\\centering}m{0.07\\paperheight}|>{\\centering}p{0.07\\paperheight}|>{\\centering}p{0.07\\paperheight}|}";
|
||||||
|
|
||||||
|
static void
|
||||||
|
print_uppercase_words (const gchar *string)
|
||||||
|
{
|
||||||
|
/* Print all uppercase-only words. */
|
||||||
|
GRegex *regex;
|
||||||
|
GMatchInfo *match_info;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
regex = g_regex_new ("\\|>.*}\\|", 0, 0, NULL);
|
||||||
|
g_regex_match_full (regex, string, -1, 0, 0, &match_info, &error);
|
||||||
|
while (g_match_info_matches (match_info))
|
||||||
|
{
|
||||||
|
gchar *word = g_match_info_fetch (match_info, 0);
|
||||||
|
g_print ("Found: %s\n", word);
|
||||||
|
g_free (word);
|
||||||
|
g_match_info_next (match_info, &error);
|
||||||
|
}
|
||||||
|
g_match_info_free (match_info);
|
||||||
|
g_regex_unref (regex);
|
||||||
|
if (error != NULL)
|
||||||
|
{
|
||||||
|
g_printerr ("Error while matching: %s\n", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
/* GRegex *regex;
|
||||||
|
GMatchInfo *match_info;
|
||||||
|
|
||||||
|
regex = g_regex_new ("s~^.*{\\|~~ ; s~\\|}.*$~~", 0, 0, NULL);
|
||||||
|
g_regex_match (regex, string, 0, &match_info);
|
||||||
|
|
||||||
|
whlie (g_match_info_matches (match_info))
|
||||||
|
{
|
||||||
|
}*/
|
||||||
|
|
||||||
|
print_uppercase_words (str);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
GList *l = NULL;
|
||||||
|
|
||||||
|
g_list_append (l, 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,101 @@
|
||||||
|
# Makefile generated by command: smake.sh -t gquark_test -Pglib-2.0
|
||||||
|
# This file is generated with smake.sh.
|
||||||
|
# You can use this make file with instruction make to
|
||||||
|
# use one of build mode: debug, profile, develop, release.
|
||||||
|
# No need to call make clean if You make with other mode,
|
||||||
|
# because the Makefile containes rules for automatically clean.
|
||||||
|
# Some usage examples:
|
||||||
|
# make # default mode is debug
|
||||||
|
# CFLAGS="-O2 -march=core2 -mtune=core2 -msse4.1 -mfpmath=sse -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=develop
|
||||||
|
# CFLAGS="-O2 -march=amdfam10 -mtune=amdfam10 -msse4a --mfpmath=sse -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=profile
|
||||||
|
# CFLAGS="-O2 -march=k6-2 -mtune=k6-2 -m3dnow --mfpmath=387 -fomit-frame-pointer -pipe" LDFLAGS="-Wl,-O1" make mode=release
|
||||||
|
# Report bugs to <mecareful@gmail.com>
|
||||||
|
|
||||||
|
#_________________________________
|
||||||
|
# ENVIRONMENT |
|
||||||
|
#________________________________|
|
||||||
|
TARGET0=gquark_test
|
||||||
|
TARGETS= $(TARGET0)
|
||||||
|
CC=cc
|
||||||
|
CXX=c++
|
||||||
|
LIBS=-lglib-2.0
|
||||||
|
SRC=
|
||||||
|
INCLUDES=-I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include
|
||||||
|
#________________________________________
|
||||||
|
# BUILD SCRIPT (don't change) |
|
||||||
|
#_______________________________________|
|
||||||
|
ifeq ($(mode),)
|
||||||
|
mode = debug
|
||||||
|
endif
|
||||||
|
ifeq ($(mode),debug)
|
||||||
|
CFLAGS := -O0 -g -DDEBUG -std=gnu99 -pedantic -Wextra -Wconversion $(CFLAGS)
|
||||||
|
LDFLAGS := $(LDFLAGS)
|
||||||
|
endif
|
||||||
|
ifeq ($(mode),profile)
|
||||||
|
CFLAGS := -O0 -g -DDEBUG -p -ftest-coverage -Wcoverage-mismatch $(CFLAGS)
|
||||||
|
LDFLAGS := -g -p $(LDFLAGS)
|
||||||
|
endif
|
||||||
|
ifeq ($(mode),develop)
|
||||||
|
CFLAGS := -O2 -g -DDEBUG $(CFLAGS)
|
||||||
|
LDFLAGS := -O1 $(LDFLAGS)
|
||||||
|
endif
|
||||||
|
ifeq ($(mode),release)
|
||||||
|
CFLAGS := -O2 $(CFLAGS)
|
||||||
|
LDFLAGS := -O1 $(LDFLAGS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
CFLAGS += -Wall $(INCLUDES)
|
||||||
|
LDFLAGS += -Wall $(LIBS)
|
||||||
|
|
||||||
|
all: change_make_options $(TARGETS)
|
||||||
|
|
||||||
|
ifneq ($(mode),debug)
|
||||||
|
ifneq ($(mode),profile)
|
||||||
|
ifneq ($(mode),develop)
|
||||||
|
ifneq ($(mode),release)
|
||||||
|
@echo "Invalid build mode."
|
||||||
|
@echo "Please use 'make mode=release', 'make mode=develop', 'make mode=profile' or 'make mode=debug'"
|
||||||
|
@exit 1
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
@echo ".........................."
|
||||||
|
@echo "Building on "$(mode)" mode "
|
||||||
|
@echo "CFLAGS=$(CFLAGS)"
|
||||||
|
@echo "LDFLAGS=$(LDFLAGS)"
|
||||||
|
@echo ".........................."
|
||||||
|
|
||||||
|
OLD_BUILD_MODE=$(shell grep ^MODE make_options.out 2>/dev/null | sed 's~^MODE=~~')
|
||||||
|
OLD_BUILD_CFLAGS=$(shell grep ^CFLAGS make_options.out 2>/dev/null | sed 's~^CFLAGS=~~')
|
||||||
|
OLD_BUILD_LDFLAGS=$(shell grep ^LDFLAGS make_options.out 2>/dev/null | sed 's~^LDFLAGS=~~')
|
||||||
|
change_make_options:
|
||||||
|
ifneq ($(mode)|$(CFLAGS)|$(LDFLAGS), $(OLD_BUILD_MODE)|$(OLD_BUILD_CFLAGS)|$(OLD_BUILD_LDFLAGS))
|
||||||
|
@echo CLEANING...
|
||||||
|
@make clean &>/dev/null
|
||||||
|
@echo "MODE=$(mode)" > make_options.out
|
||||||
|
@echo "CFLAGS=$(CFLAGS)" >> make_options.out
|
||||||
|
@echo "LDFLAGS=$(LDFLAGS)" >> make_options.out
|
||||||
|
endif
|
||||||
|
|
||||||
|
%.o :
|
||||||
|
$(CC) -c $(CFLAGS) $(SRC) -o $@ $<
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o *.out callgrind.out.* *.gcno $(TARGETS)
|
||||||
|
|
||||||
|
.PHONY: all change_make_options clean
|
||||||
|
|
||||||
|
#_________________________________
|
||||||
|
# R U L E S |
|
||||||
|
#________________________________|
|
||||||
|
target_objs0 = \
|
||||||
|
gquark_test.o
|
||||||
|
|
||||||
|
$(TARGET0): $(target_objs0)
|
||||||
|
$(CC) $(LDFLAGS) -o $@ $(target_objs0)
|
||||||
|
|
||||||
|
|
||||||
|
gquark_test.o: \
|
||||||
|
gquark_test.c
|
||||||
|
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
GQuark q1,
|
||||||
|
q2,
|
||||||
|
q3,
|
||||||
|
q4,
|
||||||
|
q5,
|
||||||
|
q6,
|
||||||
|
q7,
|
||||||
|
q8;
|
||||||
|
|
||||||
|
static const gchar *str1 = "str1",
|
||||||
|
*str2 = "str2";
|
||||||
|
|
||||||
|
gchar str3[] = "str1",
|
||||||
|
str4[] = "str2";
|
||||||
|
|
||||||
|
q1 = g_quark_from_string (str1);
|
||||||
|
q2 = g_quark_from_string (str1);
|
||||||
|
q3 = g_quark_from_static_string (str1);
|
||||||
|
q4 = g_quark_from_static_string (str1);
|
||||||
|
|
||||||
|
q5 = g_quark_from_string (str2);
|
||||||
|
q6 = g_quark_from_string (str2);
|
||||||
|
q7 = g_quark_from_static_string (str2);
|
||||||
|
q8 = g_quark_from_static_string (str2);
|
||||||
|
|
||||||
|
printf ("q[1-4] = %d, %d, %d, %d\n", q1, q2, q3, q4);
|
||||||
|
printf ("q[5-8] = %d, %d, %d, %d\n", q5, q6, q7, q8);
|
||||||
|
|
||||||
|
printf ("g_quark_to_string ():\n%s, %s, %s, %s,\n%s, %s, %s, %s\n",
|
||||||
|
g_quark_to_string (q1),
|
||||||
|
g_quark_to_string (q2),
|
||||||
|
g_quark_to_string (q3),
|
||||||
|
g_quark_to_string (q4),
|
||||||
|
g_quark_to_string (q5),
|
||||||
|
g_quark_to_string (q6),
|
||||||
|
g_quark_to_string (q7),
|
||||||
|
g_quark_to_string (q8));
|
||||||
|
|
||||||
|
printf ("g_quark_try_string (): %d, %d, %d, %d\n",
|
||||||
|
g_quark_try_string (str1),
|
||||||
|
g_quark_try_string (str2),
|
||||||
|
g_quark_try_string (str3),
|
||||||
|
g_quark_try_string (str4));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include <glib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
g_quark_from_static_string ("AAA");
|
||||||
|
printf ("%d\n", g_quark_to_string (2));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int pid;
|
||||||
|
int status, died;
|
||||||
|
|
||||||
|
pid=fork();
|
||||||
|
switch(pid) {
|
||||||
|
case -1: printf("can't fork\n");
|
||||||
|
exit(-1);
|
||||||
|
case 0 : printf(" I'm the child of PID %d\n", getppid());
|
||||||
|
printf(" My PID is %d\n", getpid());
|
||||||
|
// Ждем 2 секунды и завершаемся, следующую строку я закомментировал
|
||||||
|
// чтобы зомби "прожил" на 2 секунды больше
|
||||||
|
// sleep(2);
|
||||||
|
exit(0);
|
||||||
|
default: printf("I'm the parent.\n");
|
||||||
|
printf(" My PID is %d\n", getpid());
|
||||||
|
// Ждем завершения дочернего процесса через 10 секунд, а потом убиваем его
|
||||||
|
sleep(10);
|
||||||
|
if (pid & 1)
|
||||||
|
kill(pid,SIGKILL);
|
||||||
|
died= wait(&status);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
import sys
|
||||||
|
import glob
|
||||||
|
from chardet.universaldetector import UniversalDetector
|
||||||
|
|
||||||
|
detector = UniversalDetector()
|
||||||
|
for filename in sys.argv[1:]:
|
||||||
|
#print filename.ljust(60),
|
||||||
|
detector.reset()
|
||||||
|
for line in file(filename, 'rb'):
|
||||||
|
detector.feed(line)
|
||||||
|
if detector.done: break
|
||||||
|
detector.close()
|
||||||
|
print detector.result['encoding']
|
||||||
|
|
Loading…
Reference in New Issue