1bf215546Sopenharmony_ci#!/usr/bin/env bash
2bf215546Sopenharmony_ciset -e
3bf215546Sopenharmony_ci
4bf215546Sopenharmony_ciif [ -z "$srcdir" ]
5bf215546Sopenharmony_cithen
6bf215546Sopenharmony_ci  srcdir=$(dirname "$0")
7bf215546Sopenharmony_cifi
8bf215546Sopenharmony_ci
9bf215546Sopenharmony_ci# extract enum definition
10bf215546Sopenharmony_cidispatch_list=$(sed '/__GLXdispatchIndex/,/__GLXdispatchIndex/!d' \
11bf215546Sopenharmony_ci  "$srcdir"/../g_glxglvnddispatchindices.h)
12bf215546Sopenharmony_ci
13bf215546Sopenharmony_ci# extract values inside of enum
14bf215546Sopenharmony_cidispatch_list=$(sed '1d;$d' <<< "$dispatch_list")
15bf215546Sopenharmony_ci
16bf215546Sopenharmony_ci# remove indentation
17bf215546Sopenharmony_cidispatch_list=$(sed 's/^\s\+//' <<< "$dispatch_list")
18bf215546Sopenharmony_ci
19bf215546Sopenharmony_ci# extract function names
20bf215546Sopenharmony_cidispatch_list=$(sed 's/DI_//;s/,//' <<< "$dispatch_list")
21bf215546Sopenharmony_ci
22bf215546Sopenharmony_ci# same for commented functions, we want to keep them sorted too
23bf215546Sopenharmony_cidispatch_list=$(sed 's#// ##;s/ implemented by [a-z]\+//' <<< "$dispatch_list")
24bf215546Sopenharmony_ci
25bf215546Sopenharmony_ci# remove LAST_INDEX, as it will not be in alphabetical order
26bf215546Sopenharmony_cidispatch_list=$(sed '/LAST_INDEX/d' <<< "$dispatch_list")
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_cisorted=$(LC_ALL=C sort <<< "$dispatch_list")
29bf215546Sopenharmony_ci
30bf215546Sopenharmony_citest "$dispatch_list" = "$sorted"
31