#!/bin/bash echo "/* This file is autogenerated by $0 - do not edit */" echo echo "#include " 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 "};"