Files
zdwm/build-utils/atoms-intern.sh
2025-11-25 06:06:42 +08:00

40 lines
823 B
Bash
Executable File

#!/bin/sh
echo "/* This file is autogenerated by $0 - do not edit */"
echo
echo "#include <xcb/xproto.h>"
echo
while read atom
do
# 去掉首位空格
atom_clean=$(echo "$atom" | sed 's/^[[:space:]]*//;s/[[:space:]]$//')
# 跳过空行
if [[ -n "$atom_clean" ]]; then
echo "xcb_atom_t ${atom_clean};"
fi
done < "$1"
echo
echo "typedef struct atom_item_t {"
echo " const char *name;"
echo " size_t len;"
echo " xcb_atom_t *atom;"
echo "} atom_item_t;"
echo
echo "static atom_item_t ATOM_LIST[] = {"
while read atom
do
# 去掉首位空格
atom_clean=$(echo "$atom" | sed 's/^[[:space:]]*//;s/[[:space:]]$//')
# 跳过空行
if [[ -n "$atom_clean" ]]; then
echo " {\"${atom_clean}\", sizeof(\"${atom_clean}\") - 1, &${atom_clean}},"
fi
done < "$1"
echo "};"