/* =========================================================
 * bootstrap-timepicker.js
 * http://www.github.com/jdewit/bootstrap-timepicker
 * =========================================================
 * Copyright 2012
 *
 * Created By:
 * Joris de Wit @joris_dewit
 *
 * Contributions By:
 * Gilbert @mindeavor
 * Koen Punt info@koenpunt.nl
 * Nek
 * Chris Martin
 * Dominic Barnes contact@dominicbarnes.us
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * ========================================================= */

!function($) {

    "use strict"; // jshint ;_;

    /* TIMEPICKER PUBLIC CLASS DEFINITION
     * ================================== */
    var Timepicker = function(element, options) {
        this.$element = $(element);
        this.options = $.extend({}, $.fn.timepicker.defaults, options, this.$element.data());
        this.minuteStep = this.options.minuteStep || this.minuteStep;
        this.secondStep = this.options.secondStep || this.secondStep;
        this.showMeridian = this.options.showMeridian || this.showMeridian;
        this.showSeconds = this.options.showSeconds || this.showSeconds;
        this.showInputs = this.options.showInputs || this.showInputs;
        this.disableFocus = this.options.disableFocus || this.disableFocus;
        this.template = this.options.template || this.template;
        this.modalBackdrop = this.options.modalBackdrop || this.modalBackdrop;
        this.defaultTime = this.options.defaultTime || this.defaultTime;
        this.open = false;
        this.init();
    };

    Timepicker.prototype = {

        constructor: Timepicker

        , init: function () {
            if (this.$element.parent().hasClass('input-append')) {
                this.$element.parent('.input-append').find('.add-on').on('click', $.proxy(this.showWidget, this));
                this.$element.on({
                    focus: $.proxy(this.highlightUnit, this),
                    click: $.proxy(this.highlightUnit, this),
                    keypress: $.proxy(this.elementKeypress, this),
                    blur: $.proxy(this.blurElement, this)
                });

            } else {
                if (this.template) {
                    this.$element.on({
                        focus: $.proxy(this.showWidget, this),
                        click: $.proxy(this.showWidget, this),
                        blur: $.proxy(this.blurElement, this)
                    });
                } else {
                    this.$element.on({
                        focus: $.proxy(this.highlightUnit, this),
                        click: $.proxy(this.highlightUnit, this),
                        keypress: $.proxy(this.elementKeypress, this),
                        blur: $.proxy(this.blurElement, this)
                    });
                }
            }

            this.$widget = $(this.getTemplate()).appendTo('body');

            this.$widget.on('click', $.proxy(this.widgetClick, this));

            if (this.showInputs) {
                this.$widget.find('input').on({
                    click: function() { this.select(); },
                    keypress: $.proxy(this.widgetKeypress, this),
                    change: $.proxy(this.updateFromWidgetInputs, this)
                });
            }

            this.setDefaultTime(this.defaultTime);
        }

        , showWidget: function(e) {
            e.stopPropagation();
            e.preventDefault();

            if (this.open) {
                return;
            }

            this.$element.trigger('show');

            if (this.disableFocus) {
                this.$element.blur();
            }

            var pos = $.extend({}, this.$element.offset(), {
                height: this.$element[0].offsetHeight
            });

            this.updateFromElementVal();

            $('html')
                .trigger('click.timepicker.data-api')
                .one('click.timepicker.data-api', $.proxy(this.hideWidget, this));

            if (this.template === 'modal') {
                this.$widget.modal('show').on('hidden', $.proxy(this.hideWidget, this));
            } else {
                this.$widget.css({
                    top: pos.top + pos.height
                    , left: pos.left
                })

                if (!this.open) {
                    this.$widget.addClass('open');
                }
            }

            this.open = true;
            this.$element.trigger('shown');
        }

        , hideWidget: function(){
            this.$element.trigger('hide');

            if (this.template === 'modal') {
                this.$widget.modal('hide');
            } else {
                this.$widget.removeClass('open');
            }
            this.open = false;
            this.$element.trigger('hidden');
        }

        , widgetClick: function(e) {
            e.stopPropagation();
            e.preventDefault();

            var action = $(e.target).closest('a').data('action');
            if (action) {
                this[action]();
                this.update();
            }
        }

        , widgetKeypress: function(e) {
            var input = $(e.target).closest('input').attr('name');

            switch (e.keyCode) {
                case 9: //tab
                    if (this.showMeridian) {
                        if (input == 'meridian') {
                            this.hideWidget();
                        }
                    } else {
                        if (this.showSeconds) {
                            if (input == 'second') {
                                this.hideWidget();
                            }
                        } else {
                            if (input == 'minute') {
                                this.hideWidget();
                            }
                        }
                    }
                break;
                case 27: // escape
                    this.hideWidget();
                break;
                case 38: // up arrow
                    switch (input) {
                        case 'hour':
                            this.incrementHour();
                        break;
                        case 'minute':
                            this.incrementMinute();
                        break;
                        case 'second':
                            this.incrementSecond();
                        break;
                        case 'meridian':
                            this.toggleMeridian();
                        break;
                    }
                    this.update();
                break;
                case 40: // down arrow
                    switch (input) {
                        case 'hour':
                            this.decrementHour();
                        break;
                        case 'minute':
                            this.decrementMinute();
                        break;
                        case 'second':
                            this.decrementSecond();
                        break;
                        case 'meridian':
                            this.toggleMeridian();
                        break;
                    }
                    this.update();
                break;
            }
        }

        , elementKeypress: function(e) {
            var input = this.$element.get(0);
            switch (e.keyCode) {
                case 0: //input
                break;
                case 9: //tab
                    this.updateFromElementVal();
                    if (this.showMeridian) {
                        if (this.highlightedUnit != 'meridian') {
                            e.preventDefault();
                            this.highlightNextUnit();
                        }
                    } else {
                        if (this.showSeconds) {
                            if (this.highlightedUnit != 'second') {
                                e.preventDefault();
                                this.highlightNextUnit();
                            }
                        } else {
                            if (this.highlightedUnit != 'minute') {
                                e.preventDefault();
                                this.highlightNextUnit();
                            }
                        }
                    }
                break;
                case 27: // escape
                    this.updateFromElementVal();
                break;
                case 37: // left arrow
                    this.updateFromElementVal();
                    this.highlightPrevUnit();
                break;
                case 38: // up arrow
                    switch (this.highlightedUnit) {
                        case 'hour':
                            this.incrementHour();
                        break;
                        case 'minute':
                            this.incrementMinute();
                        break;
                        case 'second':
                            this.incrementSecond();
                        break;
                        case 'meridian':
                            this.toggleMeridian();
                        break;
                    }
                    this.updateElement();
                break;
                case 39: // right arrow
                    this.updateFromElementVal();
                    this.highlightNextUnit();
                break;
                case 40: // down arrow
                    switch (this.highlightedUnit) {
                        case 'hour':
                            this.decrementHour();
                        break;
                        case 'minute':
                            this.decrementMinute();
                        break;
                        case 'second':
                            this.decrementSecond();
                        break;
                        case 'meridian':
                            this.toggleMeridian();
                        break;
                    }
                    this.updateElement();
                break;
            }

            if (e.keyCode !== 0 && e.keyCode !== 8 && e.keyCode !== 9 && e.keyCode !== 46) {
                e.preventDefault();
            }
        }

        , setValues: function(time) {
            if (this.showMeridian) {
                var arr = time.split(' ');
                var timeArray = arr[0].split(':');
                this.meridian = arr[1];
            } else {
                var timeArray = time.split(':');
            }

            this.hour = parseInt(timeArray[0], 10);
            this.minute = parseInt(timeArray[1], 10);
            this.second = parseInt(timeArray[2], 10);

            if (isNaN(this.hour)) {
                this.hour = 0;
            }
            if (isNaN(this.minute)) {
                this.minute = 0;
            }

            if (this.showMeridian) {
                if (this.hour > 12) {
                    this.hour = 12;
                } else if (this.hour < 1) {
                    this.hour = 1;
                }

                if (this.meridian == 'am' || this.meridian == 'a') {
                    this.meridian = 'AM';
                } else if (this.meridian == 'pm' || this.meridian == 'p') {
                    this.meridian = 'PM';
                }

                if (this.meridian != 'AM' && this.meridian != 'PM') {
                    this.meridian = 'AM';
                }
            } else {
                 if (this.hour >= 24) {
                    this.hour = 23;
                } else if (this.hour < 0) {
                    this.hour = 0;
                }
            }

            if (this.minute < 0) {
                this.minute = 0;
            } else if (this.minute >= 60) {
                this.minute = 59;
            }

            if (this.showSeconds) {
                if (isNaN(this.second)) {
                    this.second = 0;
                } else if (this.second < 0) {
                    this.second = 0;
                } else if (this.second >= 60) {
                    this.second = 59;
                }
            }

            if ( this.$element.val() != '' )
                this.updateElement();
            this.updateWidget();
        }

        , setMeridian: function(meridian) {
            if (meridian == 'a' || meridian == 'am' || meridian == 'AM' ) {
                this.meridian = 'AM';
            } else if (meridian == 'p' || meridian == 'pm' || meridian == 'PM' ) {
                this.meridian = 'PM';
            } else {
                this.updateWidget();
            }

            this.updateElement();
        }

        , setDefaultTime: function(defaultTime){
            if (defaultTime) {
                if (defaultTime === 'current') {
                    var dTime = new Date();
                    var hours = dTime.getHours();
                    var minutes = Math.floor(dTime.getMinutes() / this.minuteStep) * this.minuteStep;
                    var seconds = Math.floor(dTime.getSeconds() / this.secondStep) * this.secondStep;
                    var meridian = "AM";
                    if (this.showMeridian) {
                        if (hours === 0) {
                            hours = 12;
                        } else if (hours >= 12) {
                            if (hours > 12) {
                                hours = hours - 12;
                            }
                            meridian = "PM";
                        } else {
                           meridian = "AM";
                        }
                    }
                    this.hour = hours;
                    this.minute = minutes;
                    this.second = seconds;
                    this.meridian = meridian;
                } else if (defaultTime === 'value') {
                    this.setValues(this.$element.val());
                } else {
                    this.setValues(defaultTime);
                }
                if ( this.$element.val() != '' )
                    this.updateElement();
                this.updateWidget();
            } else {
                this.hour = 0;
                this.minute = 0;
                this.second = 0;
            }
        }

        , formatTime: function(hour, minute, second, meridian) {
            hour = hour < 10 ? '0' + hour : hour;
            minute = minute < 10 ? '0' + minute : minute;
            second = second < 10 ? '0' + second : second;

            return hour + ':' + minute + (this.showSeconds ? ':' + second : '') + (this.showMeridian ? ' ' + meridian : '');
        }

        , getTime: function() {
            return this.formatTime(this.hour, this.minute, this.second, this.meridian);
        }

        , setTime: function(time) {
            this.setValues(time);
            this.update();
        }

        , update: function() {
            this.updateElement();
            this.updateWidget();
        }

        , blurElement: function() {
          this.highlightedUnit = undefined;
          this.updateFromElementVal();
        }

        , updateElement: function() {
            var time = this.getTime();

            this.$element.val(time).change();

            switch (this.highlightedUnit) {
                case 'hour':
                    this.highlightHour();
                break;
                case 'minute':
                    this.highlightMinute();
                break;
                case 'second':
                    this.highlightSecond();
                break;
                case 'meridian':
                    this.highlightMeridian();
                break;
            }
        }

        , updateWidget: function() {
            if (this.showInputs) {
                this.$widget.find('input.bootstrap-timepicker-hour').val(this.hour < 10 ? '0' + this.hour : this.hour);
                this.$widget.find('input.bootstrap-timepicker-minute').val(this.minute < 10 ? '0' + this.minute : this.minute);
                if (this.showSeconds) {
                    this.$widget.find('input.bootstrap-timepicker-second').val(this.second < 10 ? '0' + this.second : this.second);
                }
                if (this.showMeridian) {
                    this.$widget.find('input.bootstrap-timepicker-meridian').val(this.meridian);
                }
            } else {
                this.$widget.find('span.bootstrap-timepicker-hour').text(this.hour);
                this.$widget.find('span.bootstrap-timepicker-minute').text(this.minute < 10 ? '0' + this.minute : this.minute);
                if (this.showSeconds) {
                    this.$widget.find('span.bootstrap-timepicker-second').text(this.second < 10 ? '0' + this.second : this.second);
                }
                if (this.showMeridian) {
                    this.$widget.find('span.bootstrap-timepicker-meridian').text(this.meridian);
                }
            }
        }

        , updateFromElementVal: function (e) {
            var time = this.$element.val();
            if (time) {
                this.setValues(time);
                this.updateWidget();
            }
        }

        , updateFromWidgetInputs: function () {
            var time = $('input.bootstrap-timepicker-hour', this.$widget).val() + ':' +
                       $('input.bootstrap-timepicker-minute', this.$widget).val() +
                       (this.showSeconds ?
                           ':' + $('input.bootstrap-timepicker-second', this.$widget).val()
                        : '') +
                       (this.showMeridian ?
                           ' ' + $('input.bootstrap-timepicker-meridian', this.$widget).val()
                        : '');

            this.setValues(time);
        }

        , getCursorPosition: function() {
            var input = this.$element.get(0);

            if ('selectionStart' in input) {
                // Standard-compliant browsers
                return input.selectionStart;
            } else if (document.selection) {
                // IE fix
                input.focus();
                var sel = document.selection.createRange();
                var selLen = document.selection.createRange().text.length;
                sel.moveStart('character', - input.value.length);

                return sel.text.length - selLen;
            }
        }

        , highlightUnit: function () {
            var input = this.$element.get(0);

            this.position = this.getCursorPosition();
            if (this.position >= 0 && this.position <= 2) {
                this.highlightHour();
            } else if (this.position >= 3 && this.position <= 5) {
                this.highlightMinute();
            } else if (this.position >= 6 && this.position <= 8) {
                if (this.showSeconds) {
                    this.highlightSecond();
                } else {
                    this.highlightMeridian();
                }
            } else if (this.position >= 9 && this.position <= 11) {
                this.highlightMeridian();
            }
        }

        , highlightNextUnit: function() {
            switch (this.highlightedUnit) {
                case 'hour':
                    this.highlightMinute();
                break;
                case 'minute':
                    if (this.showSeconds) {
                        this.highlightSecond();
                    } else {
                        this.highlightMeridian();
                    }
                break;
                case 'second':
                    this.highlightMeridian();
                break;
                case 'meridian':
                    this.highlightHour();
                break;
            }
        }

        , highlightPrevUnit: function() {
            switch (this.highlightedUnit) {
                case 'hour':
                    this.highlightMeridian();
                break;
                case 'minute':
                    this.highlightHour();
                break;
                case 'second':
                    this.highlightMinute();
                break;
                case 'meridian':
                    if (this.showSeconds) {
                        this.highlightSecond();
                    } else {
                        this.highlightMinute();
                    }
                break;
            }
        }

        , highlightHour: function() {
            this.highlightedUnit = 'hour';
            this.$element.get(0).setSelectionRange(0,2);
        }

        , highlightMinute: function() {
            this.highlightedUnit = 'minute';
            this.$element.get(0).setSelectionRange(3,5);
        }

        , highlightSecond: function() {
            this.highlightedUnit = 'second';
            this.$element.get(0).setSelectionRange(6,8);
        }

        , highlightMeridian: function() {
            this.highlightedUnit = 'meridian';
            if (this.showSeconds) {
                this.$element.get(0).setSelectionRange(9,11);
            } else {
                this.$element.get(0).setSelectionRange(6,8);
            }
        }

        , incrementHour: function() {
            if (this.showMeridian) {
                if (this.hour === 11) {
                    this.toggleMeridian();
                } else if (this.hour === 12) {
                    return this.hour = 1;
                }
            }
            if (this.hour === 23) {
                return this.hour = 0;
            }
            this.hour = this.hour + 1;
        }

        , decrementHour: function() {
            if (this.showMeridian) {
                if (this.hour === 1) {
                    return this.hour = 12;
                }
                else if (this.hour === 12) {
                    this.toggleMeridian();
                }
            }
            if (this.hour === 0) {
                return this.hour = 23;
            }
            this.hour = this.hour - 1;
        }

        , incrementMinute: function() {
            var newVal = this.minute + this.minuteStep - (this.minute % this.minuteStep);
            if (newVal > 59) {
                this.incrementHour();
                this.minute = newVal - 60;
            } else {
                this.minute = newVal;
            }
        }

        , decrementMinute: function() {
            var newVal = this.minute - this.minuteStep;
            if (newVal < 0) {
                this.decrementHour();
                this.minute = newVal + 60;
            } else {
                this.minute = newVal;
            }
        }

        , incrementSecond: function() {
            var newVal = this.second + this.secondStep - (this.second % this.secondStep);
            if (newVal > 59) {
                this.incrementMinute();
                this.second = newVal - 60;
            } else {
                this.second = newVal;
            }
        }

        , decrementSecond: function() {
            var newVal = this.second - this.secondStep;
            if (newVal < 0) {
                this.decrementMinute();
                this.second = newVal + 60;
            } else {
                this.second = newVal;
            }
        }

        , toggleMeridian: function() {
            this.meridian = this.meridian === 'AM' ? 'PM' : 'AM';

            this.update();
        }

        , getTemplate: function() {
            if (this.options.templates[this.options.template]) {
                return this.options.templates[this.options.template];
            }
            if (this.showInputs) {
                var hourTemplate = '<input type="text" name="hour" class="bootstrap-timepicker-hour" maxlength="2"/>';
                var minuteTemplate = '<input type="text" name="minute" class="bootstrap-timepicker-minute" maxlength="2"/>';
                var secondTemplate = '<input type="text" name="second" class="bootstrap-timepicker-second" maxlength="2"/>';
                var meridianTemplate = '<input type="text" name="meridian" class="bootstrap-timepicker-meridian" maxlength="2"/>';
            } else {
                var hourTemplate = '<span class="bootstrap-timepicker-hour"></span>';
                var minuteTemplate = '<span class="bootstrap-timepicker-minute"></span>';
                var secondTemplate = '<span class="bootstrap-timepicker-second"></span>';
                var meridianTemplate = '<span class="bootstrap-timepicker-meridian"></span>';
            }
            var templateContent = '<table class="'+ (this.showSeconds ? 'show-seconds' : '') +' '+ (this.showMeridian ? 'show-meridian' : '') +'">'+
                                       '<tr>'+
                                           '<td><a href="#" data-action="incrementHour"><i class="icon-chevron-up"></i></a></td>'+
                                           '<td class="separator"> </td>'+
                                           '<td><a href="#" data-action="incrementMinute"><i class="icon-chevron-up"></i></a></td>'+
                                           (this.showSeconds ?
                                               '<td class="separator"> </td>'+
                                               '<td><a href="#" data-action="incrementSecond"><i class="icon-chevron-up"></i></a></td>'
                                           : '') +
                                           (this.showMeridian ?
                                               '<td class="separator"> </td>'+
                                               '<td class="meridian-column"><a href="#" data-action="toggleMeridian"><i class="icon-chevron-up"></i></a></td>'
                                           : '') +
                                       '</tr>'+
                                       '<tr>'+
                                           '<td>'+ hourTemplate +'</td> '+
                                           '<td class="separator">:</td>'+
                                           '<td>'+ minuteTemplate +'</td> '+
                                           (this.showSeconds ?
                                                '<td class="separator">:</td>'+
                                                '<td>'+ secondTemplate +'</td>'
                                           : '') +
                                           (this.showMeridian ?
                                                '<td class="separator"> </td>'+
                                                '<td>'+ meridianTemplate +'</td>'
                                           : '') +
                                       '</tr>'+
                                       '<tr>'+
                                           '<td><a href="#" data-action="decrementHour"><i class="icon-chevron-down"></i></a></td>'+
                                           '<td class="separator"></td>'+
                                           '<td><a href="#" data-action="decrementMinute"><i class="icon-chevron-down"></i></a></td>'+
                                           (this.showSeconds ?
                                                '<td class="separator"> </td>'+
                                                '<td><a href="#" data-action="decrementSecond"><i class="icon-chevron-down"></i></a></td>'
                                           : '') +
                                           (this.showMeridian ?
                                                '<td class="separator"> </td>'+
                                                '<td><a href="#" data-action="toggleMeridian"><i class="icon-chevron-down"></i></a></td>'
                                           : '') +
                                       '</tr>'+
                                   '</table>';

            var template;
            switch(this.options.template) {
                case 'modal':
                    template = '<div class="bootstrap-timepicker modal hide fade in" style="top: 30%; margin-top: 0; width: 200px; margin-left: -100px;" data-backdrop="'+ (this.modalBackdrop ? 'true' : 'false') +'">'+
                                   '<div class="modal-header">'+
                                       '<a href="#" class="close" data-dismiss="modal">×</a>'+
                                       '<h3>Pick a Time</h3>'+
                                   '</div>'+
                                   '<div class="modal-content">'+
                                        templateContent +
                                   '</div>'+
                                   '<div class="modal-footer">'+
                                       '<a href="#" class="btn btn-primary" data-dismiss="modal">Ok</a>'+
                                   '</div>'+
                               '</div>';

                break;
                case 'dropdown':
                    template = '<div class="bootstrap-timepicker dropdown-menu">'+
                                    templateContent +
                               '</div>';
                break;

            }
            return template;
        }
    };

    /* TIMEPICKER PLUGIN DEFINITION
     * =========================== */

    $.fn.timepicker = function (option) {
        return this.each(function () {
            var $this = $(this)
            , data = $this.data('timepicker')
            , options = typeof option == 'object' && option;
            if (!data) {
                $this.data('timepicker', (data = new Timepicker(this, options)));
            }
            if (typeof option == 'string') {
                data[option]();
            }
        })
    }

    $.fn.timepicker.defaults = {
      minuteStep: 15
    , secondStep: 15
    , disableFocus: false
    , defaultTime: 'current'
    , showSeconds: false
    , showInputs: true
    , showMeridian: true
    , template: 'dropdown'
    , modalBackdrop: false
    , templates: {} // set custom templates
    }

    $.fn.timepicker.Constructor = Timepicker
}(window.jQuery);

{'repo_name': 'xiaoyao-work/TP-Admin', 'stars': '157', 'repo_language': 'JavaScript', 'file_name': 'formvalidatorregex.js', 'mime_type': 'text/plain', 'hash': -1797084573695940430, 'source_dataset': 'data'}


package placebo.objekt

import org.scalatest.FunSuite
import pkg._

@placebo object CPreToplevelNocomp { override def toString = "CPreToplevelNocomp" }
class CPreToplevelPrecomp
@placebo object CPreToplevelPrecomp { override def toString = "CPreToplevelPrecomp" }
@placebo object CPreToplevelPostcomp { override def toString = "CPreToplevelPostcomp" }
class CPreToplevelPostcomp

class PlaceboClass extends FunSuite {
  val classs = scala.collection.mutable.ListBuffer[Any]()
  classs += CPreToplevelNocomp
  classs += CPreToplevelPrecomp
  classs += CPreToplevelPostcomp
  classs += CPostToplevelNocomp
  classs += CPostToplevelPrecomp
  classs += CPostToplevelPostcomp

  @placebo object CPreMemberNocomp { override def toString = "CPreMemberNocomp" }
  class CPreMemberPrecomp
  @placebo object CPreMemberPrecomp { override def toString = "CPreMemberPrecomp" }
  @placebo object CPreMemberPostcomp { override def toString = "CPreMemberPostcomp" }
  class CPreMemberPostcomp
  classs += CPreMemberNocomp
  classs += CPreMemberPrecomp
  classs += CPreMemberPostcomp
  classs += CPostMemberNocomp
  classs += CPostMemberPrecomp
  classs += CPostMemberPostcomp
  @placebo object CPostMemberNocomp { override def toString = "CPostMemberNocomp" }
  class CPostMemberPrecomp
  @placebo object CPostMemberPrecomp { override def toString = "CPostMemberPrecomp" }
  @placebo object CPostMemberPostcomp { override def toString = "CPostMemberPostcomp" }
  class CPostMemberPostcomp

  test("combo") {
    @placebo object CPreLocalNocomp { override def toString = "CPreLocalNocomp" }
    class CPreLocalPrecomp
    @placebo object CPreLocalPrecomp { override def toString = "CPreLocalPrecomp" }
    @placebo object CPreLocalPostcomp { override def toString = "CPreLocalPostcomp" }
    class CPreLocalPostcomp
    classs += CPreLocalNocomp
    classs += CPreLocalPrecomp
    classs += CPreLocalPostcomp
    classs += CPostLocalNocomp
    classs += CPostLocalPrecomp
    classs += CPostLocalPostcomp
    @placebo object CPostLocalNocomp { override def toString = "CPostLocalNocomp" }
    class CPostLocalPrecomp
    @placebo object CPostLocalPrecomp { override def toString = "CPostLocalPrecomp" }
    @placebo object CPostLocalPostcomp { override def toString = "CPostLocalPostcomp" }
    class CPostLocalPostcomp

    assert(classs.mkString("\n") === """
      |CPreToplevelNocomp
      |CPreToplevelPrecomp
      |CPreToplevelPostcomp
      |CPostToplevelNocomp
      |CPostToplevelPrecomp
      |CPostToplevelPostcomp
      |CPreMemberNocomp
      |CPreMemberPrecomp
      |CPreMemberPostcomp
      |CPostMemberNocomp
      |CPostMemberPrecomp
      |CPostMemberPostcomp
      |CPreLocalNocomp
      |CPreLocalPrecomp
      |CPreLocalPostcomp
      |CPostLocalNocomp
      |CPostLocalPrecomp
      |CPostLocalPostcomp
    """.trim.stripMargin)
  }
}

@placebo object CPostToplevelNocomp { override def toString = "CPostToplevelNocomp" }
class CPostToplevelPrecomp
@placebo object CPostToplevelPrecomp { override def toString = "CPostToplevelPrecomp" }
@placebo object CPostToplevelPostcomp { override def toString = "CPostToplevelPostcomp" }
class CPostToplevelPostcomp

{'repo_name': 'scalamacros/paradise', 'stars': '154', 'repo_language': 'Scala', 'file_name': 'Macros_1.scala', 'mime_type': 'text/plain', 'hash': 7452630663749883820, 'source_dataset': 'data'}


{'repo_name': 'microsoft/Application-Insights-Workbooks', 'stars': '120', 'repo_language': 'JSON', 'file_name': 'settings.json', 'mime_type': 'text/plain', 'hash': 2673099335912014733, 'source_dataset': 'data'}


// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

'use strict';
const common = require('../common');
if (!common.hasCrypto)
  common.skip('missing crypto');

const assert = require('assert');
const fixtures = require('../common/fixtures');
const net = require('net');
const tls = require('tls');

let clientError = null;

const server = tls.createServer({
  cert: fixtures.readKey('agent1-cert.pem'),
  key: fixtures.readKey('agent1-key.pem'),
}, common.mustNotCall()).on('tlsClientError', function(err, conn) {
  assert(!clientError && conn);
  clientError = err;
  server.close();
}).listen(0, function() {
  net.connect(this.address().port, function() {
    // Destroy the socket once it is connected, so the server sees ECONNRESET.
    this.destroy();
  }).on('error', common.mustNotCall());
});

process.on('exit', function() {
  assert(clientError);
  assert(/socket hang up/.test(clientError.message));
  assert(/ECONNRESET/.test(clientError.code));
});

{'repo_name': 'mceSystems/node-jsc', 'stars': '178', 'repo_language': 'JavaScript', 'file_name': 'dnt_helper.js', 'mime_type': 'text/plain', 'hash': 5748505768540261750, 'source_dataset': 'data'}


package cc.bitky.clusterdeviceplatform.client.netty.handler;

import org.springframework.stereotype.Service;

import cc.bitky.clusterdeviceplatform.messageutils.config.FrameSetting;
import cc.bitky.clusterdeviceplatform.messageutils.define.frame.FrameMajor;
import cc.bitky.clusterdeviceplatform.messageutils.define.frame.FrameMajorHeader;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

/**
 * 帧识别 - 入站处理器 分割出并向后继处理器传递一个完整的主帧数据体及主帧信息 bean
 */
@Service
@ChannelHandler.Sharable
public class FrameRecognitionInBoundHandler extends SimpleChannelInboundHandler<ByteBuf> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, ByteBuf byteBuf) throws Exception {
        while (true) {
            if (byteBuf.readableBytes() < FrameSetting.FRAME_HEAD_LENGTH) {
                return;
            }
            if (byteBuf.readByte() != FrameSetting.MAJOR_FRAME_HEAD_1
                    || byteBuf.readByte() != FrameSetting.MAJOR_FRAME_HEAD_2) {
                return;
            }
            int groupId = byteBuf.readByte() & 0xFF;
            int msgId = byteBuf.readByte() & 0xFF;
            int deviceId = byteBuf.readByte() & 0xFF;
            int backupMsg = byteBuf.readByte() & 0xFF;
            int dataLength = byteBuf.readShort() & 0xFFFF;
            FrameMajorHeader headMsg = new FrameMajorHeader(msgId, groupId, deviceId, dataLength, backupMsg);
            ByteBuf subBuf = ctx.alloc().buffer(dataLength);
            byteBuf.readBytes(subBuf, dataLength);
            ctx.fireChannelRead(new FrameMajor(headMsg, subBuf));
        }
    }
}

{'repo_name': 'bitkylin/ClusterDeviceControlPlatform', 'stars': '301', 'repo_language': 'Java', 'file_name': 'NetCardFactory.java', 'mime_type': 'text/x-java', 'hash': -69903837406283203, 'source_dataset': 'data'}


# Copyright Contributors to the Amundsen project.
# SPDX-License-Identifier: Apache-2.0

import abc
from typing import Dict

from flask import Response

class BasePreviewClient(abc.ABC):
    @abc.abstractmethod
    def __init__(self) -> None:
        pass  # pragma: no cover

    @abc.abstractmethod
    def get_preview_data(self, params: Dict, optionalHeaders: Dict = None) -> Response:
        """
        Returns a Response object, where the response data represents a json object
        with the preview data accessible on 'preview_data' key. The preview data should
        match amundsen_application.models.preview_data.PreviewDataSchema
        """
        raise NotImplementedError  # pragma: no cover

{'repo_name': 'lyft/amundsenfrontendlibrary', 'stars': '238', 'repo_language': 'TypeScript', 'file_name': 'config.yml', 'mime_type': 'text/plain', 'hash': 3794130485446403605, 'source_dataset': 'data'}


/*
 * Copyright (C) 2017 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "config.h"
#include "DOMFileSystem.h"

#include "File.h"
#include "FileSystemDirectoryEntry.h"
#include "FileSystemFileEntry.h"
#include "ScriptExecutionContext.h"
#include <wtf/CrossThreadCopier.h>
#include <wtf/FileMetadata.h>
#include <wtf/FileSystem.h>
#include <wtf/IsoMallocInlines.h>
#include <wtf/UUID.h>
#include <wtf/text/StringBuilder.h>

namespace WebCore {

WTF_MAKE_ISO_ALLOCATED_IMPL(DOMFileSystem);

struct ListedChild {
    String filename;
    FileMetadata::Type type;

    ListedChild isolatedCopy() const { return { filename.isolatedCopy(), type }; }
};

static ExceptionOr<Vector<ListedChild>> listDirectoryWithMetadata(const String& fullPath)
{
    ASSERT(!isMainThread());
    if (!FileSystem::fileIsDirectory(fullPath, FileSystem::ShouldFollowSymbolicLinks::No))
        return Exception { NotFoundError, "Path no longer exists or is no longer a directory" };

    auto childPaths = FileSystem::listDirectory(fullPath, "*");
    Vector<ListedChild> listedChildren;
    listedChildren.reserveInitialCapacity(childPaths.size());
    for (auto& childPath : childPaths) {
        auto metadata = FileSystem::fileMetadata(childPath);
        if (!metadata || metadata.value().isHidden)
            continue;
        listedChildren.uncheckedAppend(ListedChild { FileSystem::pathGetFileName(childPath), metadata.value().type });
    }
    return listedChildren;
}

static ExceptionOr<Vector<Ref<FileSystemEntry>>> toFileSystemEntries(ScriptExecutionContext& context, DOMFileSystem& fileSystem, ExceptionOr<Vector<ListedChild>>&& listedChildren, const String& parentVirtualPath)
{
    ASSERT(isMainThread());
    if (listedChildren.hasException())
        return listedChildren.releaseException();

    Vector<Ref<FileSystemEntry>> entries;
    entries.reserveInitialCapacity(listedChildren.returnValue().size());
    for (auto& child : listedChildren.returnValue()) {
        String virtualPath = parentVirtualPath + "/" + child.filename;
        switch (child.type) {
        case FileMetadata::Type::File:
            entries.uncheckedAppend(FileSystemFileEntry::create(context, fileSystem, virtualPath));
            break;
        case FileMetadata::Type::Directory:
            entries.uncheckedAppend(FileSystemDirectoryEntry::create(context, fileSystem, virtualPath));
            break;
        default:
            break;
        }
    }
    return entries;
}

// https://wicg.github.io/entries-api/#name
static bool isValidPathNameCharacter(UChar c)
{
    return c != '\0' && c != '/' && c != '\\';
}

// https://wicg.github.io/entries-api/#path-segment
static bool isValidPathSegment(StringView segment)
{
    if (segment.isEmpty() || segment == "." || segment == "..")
        return true;

    for (unsigned i = 0; i < segment.length(); ++i) {
        if (!isValidPathNameCharacter(segment[i]))
            return false;
    }
    return true;
}

static bool isZeroOrMorePathSegmentsSeparatedBySlashes(StringView string)
{
    auto segments = string.split('/');
    for (auto segment : segments) {
        if (!isValidPathSegment(segment))
            return false;
    }
    return true;
}

// https://wicg.github.io/entries-api/#relative-path
static bool isValidRelativeVirtualPath(StringView virtualPath)
{
    if (virtualPath.isEmpty())
        return false;

    if (virtualPath[0] == '/')
        return false;

    return isZeroOrMorePathSegmentsSeparatedBySlashes(virtualPath);
}

// https://wicg.github.io/entries-api/#valid-path
static bool isValidVirtualPath(StringView virtualPath)
{
    if (virtualPath.isEmpty())
        return true;
    if (virtualPath[0] == '/') {
        // An absolute path is a string consisting of '/' (U+002F SOLIDUS) followed by one or more path segments joined by '/' (U+002F SOLIDUS).
        return isZeroOrMorePathSegmentsSeparatedBySlashes(virtualPath.substring(1));
    }
    return isValidRelativeVirtualPath(virtualPath);
}

DOMFileSystem::DOMFileSystem(Ref<File>&& file)
    : m_name(createCanonicalUUIDString())
    , m_file(WTFMove(file))
    , m_rootPath(FileSystem::directoryName(m_file->path()))
    , m_workQueue(WorkQueue::create("DOMFileSystem work queue"))
{
    ASSERT(!m_rootPath.endsWith('/'));
}

DOMFileSystem::~DOMFileSystem() = default;

Ref<FileSystemDirectoryEntry> DOMFileSystem::root(ScriptExecutionContext& context)
{
    return FileSystemDirectoryEntry::create(context, *this, "/"_s);
}

Ref<FileSystemEntry> DOMFileSystem::fileAsEntry(ScriptExecutionContext& context)
{
    if (m_file->isDirectory())
        return FileSystemDirectoryEntry::create(context, *this, "/" + m_file->name());
    return FileSystemFileEntry::create(context, *this, "/" + m_file->name());
}

static ExceptionOr<String> validatePathIsExpectedType(const String& fullPath, String&& virtualPath, FileMetadata::Type expectedType)
{
    ASSERT(!isMainThread());

    auto metadata = FileSystem::fileMetadata(fullPath);
    if (!metadata || metadata.value().isHidden)
        return Exception { NotFoundError, "Path does not exist"_s };

    if (metadata.value().type != expectedType)
        return Exception { TypeMismatchError, "Entry at path does not have expected type" };

    return WTFMove(virtualPath);
}

static Optional<FileMetadata::Type> fileType(const String& fullPath)
{
    auto metadata = FileSystem::fileMetadata(fullPath);
    if (!metadata || metadata.value().isHidden)
        return WTF::nullopt;
    return metadata.value().type;
}

// https://wicg.github.io/entries-api/#resolve-a-relative-path
static String resolveRelativeVirtualPath(StringView baseVirtualPath, StringView relativeVirtualPath)
{
    ASSERT(baseVirtualPath[0] == '/');
    if (!relativeVirtualPath.isEmpty() && relativeVirtualPath[0] == '/')
        return relativeVirtualPath.length() == 1 ? relativeVirtualPath.toString() : resolveRelativeVirtualPath("/", relativeVirtualPath.substring(1));

    Vector<StringView> virtualPathSegments;
    for (auto segment : baseVirtualPath.split('/'))
        virtualPathSegments.append(segment);

    for (auto segment : relativeVirtualPath.split('/')) {
        ASSERT(!segment.isEmpty());
        if (segment == ".")
            continue;
        if (segment == "..") {
            if (!virtualPathSegments.isEmpty())
                virtualPathSegments.removeLast();
            continue;
        }
        virtualPathSegments.append(segment);
    }

    if (virtualPathSegments.isEmpty())
        return "/"_s;

    StringBuilder builder;
    for (auto& segment : virtualPathSegments) {
        builder.append('/');
        builder.append(segment);
    }
    return builder.toString();
}

// https://wicg.github.io/entries-api/#evaluate-a-path
String DOMFileSystem::evaluatePath(StringView virtualPath)
{
    ASSERT(virtualPath[0] == '/');

    Vector<StringView> resolvedComponents;
    for (auto component : virtualPath.split('/')) {
        if (component == ".")
            continue;
        if (component == "..") {
            if (!resolvedComponents.isEmpty())
                resolvedComponents.removeLast();
            continue;
        }
        resolvedComponents.append(component);
    }

    return FileSystem::pathByAppendingComponents(m_rootPath, resolvedComponents);
}

void DOMFileSystem::listDirectory(ScriptExecutionContext& context, FileSystemDirectoryEntry& directory, DirectoryListingCallback&& completionHandler)
{
    ASSERT(&directory.filesystem() == this);

    auto directoryVirtualPath = directory.virtualPath();
    auto fullPath = evaluatePath(directoryVirtualPath);
    if (fullPath == m_rootPath) {
        Vector<Ref<FileSystemEntry>> children;
        children.append(fileAsEntry(context));
        completionHandler(WTFMove(children));
        return;
    }

    m_workQueue->dispatch([this, context = makeRef(context), completionHandler = WTFMove(completionHandler), fullPath = crossThreadCopy(fullPath), directoryVirtualPath = crossThreadCopy(directoryVirtualPath)]() mutable {
        auto listedChildren = listDirectoryWithMetadata(fullPath);
        callOnMainThread([this, context = WTFMove(context), completionHandler = WTFMove(completionHandler), listedChildren = crossThreadCopy(listedChildren), directoryVirtualPath = directoryVirtualPath.isolatedCopy()]() mutable {
            completionHandler(toFileSystemEntries(context, *this, WTFMove(listedChildren), directoryVirtualPath));
        });
    });
}

void DOMFileSystem::getParent(ScriptExecutionContext& context, FileSystemEntry& entry, GetParentCallback&& completionCallback)
{
    ASSERT(&entry.filesystem() == this);

    auto virtualPath = resolveRelativeVirtualPath(entry.virtualPath(), "..");
    ASSERT(virtualPath[0] == '/');
    auto fullPath = evaluatePath(virtualPath);
    m_workQueue->dispatch([this, context = makeRef(context), fullPath = crossThreadCopy(fullPath), virtualPath = crossThreadCopy(virtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
        auto validatedVirtualPath = validatePathIsExpectedType(fullPath, WTFMove(virtualPath), FileMetadata::Type::Directory);
        callOnMainThread([this, context = WTFMove(context), validatedVirtualPath = crossThreadCopy(validatedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
            if (validatedVirtualPath.hasException())
                completionCallback(validatedVirtualPath.releaseException());
            else
                completionCallback(FileSystemDirectoryEntry::create(context, *this, validatedVirtualPath.releaseReturnValue()));
        });
    });
}

// https://wicg.github.io/entries-api/#dom-filesystemdirectoryentry-getfile
// https://wicg.github.io/entries-api/#dom-filesystemdirectoryentry-getdirectory
void DOMFileSystem::getEntry(ScriptExecutionContext& context, FileSystemDirectoryEntry& directory, const String& virtualPath, const FileSystemDirectoryEntry::Flags& flags, GetEntryCallback&& completionCallback)
{
    ASSERT(&directory.filesystem() == this);

    if (!isValidVirtualPath(virtualPath)) {
        callOnMainThread([completionCallback = WTFMove(completionCallback)] {
            completionCallback(Exception { TypeMismatchError, "Path is invalid"_s });
        });
        return;
    }

    if (flags.create) {
        callOnMainThread([completionCallback = WTFMove(completionCallback)] {
            completionCallback(Exception { SecurityError, "create flag cannot be true"_s });
        });
        return;
    }

    auto resolvedVirtualPath = resolveRelativeVirtualPath(directory.virtualPath(), virtualPath);
    ASSERT(resolvedVirtualPath[0] == '/');
    auto fullPath = evaluatePath(resolvedVirtualPath);
    if (fullPath == m_rootPath) {
        callOnMainThread([this, context = makeRef(context), completionCallback = WTFMove(completionCallback)]() mutable {
            completionCallback(Ref<FileSystemEntry> { root(context) });
        });
        return;
    }

    m_workQueue->dispatch([this, context = makeRef(context), fullPath = crossThreadCopy(fullPath), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
        auto entryType = fileType(fullPath);
        callOnMainThread([this, context = WTFMove(context), resolvedVirtualPath = crossThreadCopy(resolvedVirtualPath), entryType, completionCallback = WTFMove(completionCallback)]() mutable {
            if (!entryType) {
                completionCallback(Exception { NotFoundError, "Cannot find entry at given path"_s });
                return;
            }
            switch (entryType.value()) {
            case FileMetadata::Type::Directory:
                completionCallback(Ref<FileSystemEntry> { FileSystemDirectoryEntry::create(context, *this, resolvedVirtualPath) });
                break;
            case FileMetadata::Type::File:
                completionCallback(Ref<FileSystemEntry> { FileSystemFileEntry::create(context, *this, resolvedVirtualPath) });
                break;
            default:
                completionCallback(Exception { NotFoundError, "Cannot find entry at given path"_s });
                break;
            }
        });
    });
}

void DOMFileSystem::getFile(ScriptExecutionContext& context, FileSystemFileEntry& fileEntry, GetFileCallback&& completionCallback)
{
    auto virtualPath = fileEntry.virtualPath();
    auto fullPath = evaluatePath(virtualPath);
    m_workQueue->dispatch([context = makeRef(context), fullPath = crossThreadCopy(fullPath), virtualPath = crossThreadCopy(virtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
        auto validatedVirtualPath = validatePathIsExpectedType(fullPath, WTFMove(virtualPath), FileMetadata::Type::File);
        callOnMainThread([context = WTFMove(context), fullPath = crossThreadCopy(fullPath), validatedVirtualPath = crossThreadCopy(validatedVirtualPath), completionCallback = WTFMove(completionCallback)]() mutable {
            if (validatedVirtualPath.hasException())
                completionCallback(validatedVirtualPath.releaseException());
            else
                completionCallback(File::create(fullPath));
        });
    });
}

} // namespace WebCore

{'repo_name': 'ultralight-ux/WebCore', 'stars': '113', 'repo_language': 'C++', 'file_name': 'WebKitTargetConditionals.xcconfig', 'mime_type': 'text/plain', 'hash': -2505752378736258276, 'source_dataset': 'data'}


---
title: CREATE TABLE
linkTitle: CREATE TABLE
summary: Create a new table in a database
description: CREATE TABLE
block_indexing: true
menu:
  v2.0:
    identifier: api-ysql-commands-create-table
    parent: api-ysql-commands
isTocNested: true
showAsideToc: true
---

## Synopsis

Use the `CREATE TABLE` statement to create a new table in a database. It defines the table name, column names and types, primary key, and table properties.

## Syntax

      Grammar

      Diagram

    {{% includeMarkdown "../syntax_resources/commands/create_table,table_elem,column_constraint,table_constraint,key_columns,hash_columns,range_columns,storage_parameters,storage_parameter,index_parameters,references_clause.grammar.md" /%}}

    {{% includeMarkdown "../syntax_resources/commands/create_table,table_elem,column_constraint,table_constraint,key_columns,hash_columns,range_columns,storage_parameters,storage_parameter,index_parameters,references_clause.diagram.md" /%}}

## Semantics

Create a table with *table_name*. If `qualified_name` already exists in the specified database, an error will be raised unless the `IF NOT EXISTS` clause is used.

### Primary key

Primary key can be defined in either `column_constraint` or `table_constraint`, but not in both.
There are two types of primary key columns:

- `Hash primary key columns`: The primary key may have zero or more leading hash-partitioned columns.
By default, only the first column is treated as the hash-partition column. But this behavior can be modified by explicit use of the HASH annotation.

- `Range primary key columns`: A table can have zero or more range primary key columns and it controls the top-level ordering of rows within a table (if there are no hash partition columns) or the ordering of rows among rows that share a common set of hash partitioned column values. By default, the range primary key columns are stored in ascending order. But this behavior can be controlled by explicit use of `ASC` or `DESC`.

For example, if the primary key specification is `PRIMARY KEY ((a, b) HASH, c DESC)` then columns `a` & `b` are used together to hash partition the table, and rows that share the same values for `a` and `b` are stored in descending order of their value for `c`.

If the primary key specification is `PRIMARY KEY(a, b)`, then column `a` is used to hash partition
the table and rows that share the same value for `a` are stored in ascending order of their value
for `b`.

### Foreign key

`FOREIGN KEY` and `REFERENCES` specifies that the set of columns can only contain values that are present in the referenced column(s) of the referenced table. It is used to enforce referential integrity of data.

### Unique

This enforces that the set of columns specified in the `UNIQUE` constraint are unique in the table, that is, no two rows can have the same values for the set of columns specified in the `UNIQUE` constraint.

### Check

This is used to enforce that data in the specified table meets the requirements specified in the `CHECK` clause.

### Default

This clause is used to specify a default value for the column. If an `INSERT` statement does not specify a value for the column, then the default value is used. If no default is specified for a column, then the default is NULL.

### Temporary or Temp

Using this qualifier will create a temporary table. Temporary tables are only visible in the current client session or transaction in which they are created and are automatically dropped at the end of the session or transaction. Any indexes created on temporary tables are temporary as well.

### Split Into

The `SPLIT INTO` clause specifies the number of tablets that will be created for the table. This is useful for two data center (2DC) deployments. See example below: [Create CDC table specifying number of tablets](#create-cdc-table-specifying-number-of-tablets).

### Colocated

{{< note title="Note" >}}

This feature is currently in [Beta](../../../../faq/general/#what-is-the-definition-of-the-beta-feature-tag).

{{< /note >}}

For colocated databases, specify `false` to opt this table out of colocation. This means that the table won't be stored on the same tablet as the rest of the tables for this database, but instead, will have its own set of tablets.
Use this option for large tables that need to be scaled out. See [colocated tables architecture](https://github.com/yugabyte/yugabyte-db/blob/master/architecture/design/ysql-colocated-tables.md) for more details on when colocation is useful.

Note that `colocated = true` has no effect if the database that this table is part of is not colocated since colocation today is supported only at the database level.

### Storage parameters

Storage parameters [as defined by PostgreSQL](https://www.postgresql.org/docs/11/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS) are ignored and only present for compatibility with PostgreSQL.

## Examples

### Table with primary key

```postgresql
yugabyte=# CREATE TABLE sample(k1 int,
                               k2 int,
                               v1 int,
                               v2 text,
                               PRIMARY KEY (k1, k2));
```

In this example, the first column `k1` will be `HASH`, while second column `k2` will be `ASC`.

```
yugabyte=# \d sample
               Table "public.sample"
 Column |  Type   | Collation | Nullable | Default
--------+---------+-----------+----------+---------
 k1     | integer |           | not null |
 k2     | integer |           | not null |
 v1     | integer |           |          |
 v2     | text    |           |          |
Indexes:
    "sample_pkey" PRIMARY KEY, lsm (k1 HASH, k2)
```

### Table with range primary key

```postgresql
yugabyte=# CREATE TABLE range(k1 int,
                              k2 int,
                              v1 int,
                              v2 text,
                              PRIMARY KEY (k1 ASC, k2 DESC));
```

### Table with check constraint

```postgresql
yugabyte=# CREATE TABLE student_grade(student_id int,
                                      class_id int,
                                      term_id int,
                                      grade int CHECK (grade >= 0 AND grade <= 10),
                                      PRIMARY KEY (student_id, class_id, term_id));
```

### Table with default value

```postgresql
yugabyte=# CREATE TABLE cars(id int PRIMARY KEY,
                             brand text CHECK (brand in ('X', 'Y', 'Z')),
                             model text NOT NULL,
                             color text NOT NULL DEFAULT 'WHITE' CHECK (color in ('RED', 'WHITE', 'BLUE')));
```

### Table with foreign key constraint

Define two tables with a foreign keys constraint.

```postgresql
yugabyte=# CREATE TABLE products(id int PRIMARY KEY,
                                 descr text);
yugabyte=# CREATE TABLE orders(id int PRIMARY KEY,
                               pid int REFERENCES products(id) ON DELETE CASCADE,
                               amount int);
```

Insert some rows.

```postgresql
yugabyte=# SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL SERIALIZABLE;
yugabyte=# INSERT INTO products VALUES (1, 'Phone X'), (2, 'Tablet Z');
yugabyte=# INSERT INTO orders VALUES (1, 1, 3), (2, 1, 3), (3, 2, 2);

yugabyte=# SELECT o.id AS order_id, p.id as product_id, p.descr, o.amount FROM products p, orders o WHERE o.pid = p.id;
```

```
order_id | product_id |  descr   | amount
----------+------------+----------+--------
        1 |          1 | Phone X  |      3
        2 |          1 | Phone X  |      3
        3 |          2 | Tablet Z |      2
(3 rows)
```

Inserting a row referencing a non-existent product is not allowed.

```postgresql
yugabyte=# INSERT INTO orders VALUES (1, 3, 3);
```

```
ERROR:  insert or update on table "orders" violates foreign key constraint "orders_pid_fkey"
DETAIL:  Key (pid)=(3) is not present in table "products".
```

Deleting a product will cascade to all orders (as defined in the `CREATE TABLE` statement above).

```postgresql
yugabyte=# DELETE from products where id = 1;
yugabyte=# SELECT o.id AS order_id, p.id as product_id, p.descr, o.amount FROM products p, orders o WHERE o.pid = p.id;
```

```
 order_id | product_id |  descr   | amount
----------+------------+----------+--------
        3 |          2 | Tablet Z |      2
(1 row)
```

### Table with unique constraint

```postgresql
yugabyte=# CREATE TABLE translations(message_id int UNIQUE,
                                     message_txt text);
```

### Create table specifying number of tablets

You can use the `CREATE TABLE` statement with the `SPLIT INTO` clause to specify the number of tablets for the table.
This is useful for two data center (2DC) deployments that require identical number of tablets on both clusters.

```postgresql
yugabyte=# CREATE TABLE tracking (id int PRIMARY KEY) SPLIT (INTO 10 TABLETS);
```

### Opt table out of colocation

```postgresql
yugabyte=# CREATE DATABASE company WITH colocated = true;

yugabyte=# CREATE TABLE employee(id INT PRIMARY KEY, name TEXT) WITH (colocated = false);
```

In this example, database `company` is colocated and all tables other than the `employee` table are stored on a single tablet.

## See also

- [`ALTER TABLE`](../ddl_alter_table)
- [`CREATE TABLE AS`](../ddl_create_table_as)
- [`DROP TABLE`](../ddl_drop_table)

{'repo_name': 'yugabyte/yugabyte-db', 'stars': '4139', 'repo_language': 'C', 'file_name': 'README.md', 'mime_type': 'text/plain', 'hash': -4778606863845405407, 'source_dataset': 'data'}


#define ESCAPE(s)s:Print"ESCAPE("&#s&")"
ESCAPE(Print"#define ESCAPE(s)s:Print""ESCAPE(""&#s&"")""")

{'repo_name': 'MakeNowJust/quine', 'stars': '249', 'repo_language': 'E', 'file_name': 'quine.ch', 'mime_type': 'text/plain', 'hash': -6910781291043986953, 'source_dataset': 'data'}


# coding=utf-8
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar
import warnings

from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error
from azure.core.pipeline import PipelineResponse
from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest
from azure.mgmt.core.exceptions import ARMErrorFormat

from ... import models

T = TypeVar('T')
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]

class OperationOperations:
    """OperationOperations async operations.

    You should not instantiate this class directly. Instead, you should create a Client instance that
    instantiates it for you and attaches it as an attribute.

    :ivar models: Alias to model classes used in this operation group.
    :type models: ~connected_machine.models
    :param client: Client for service requests.
    :param config: Configuration of service client.
    :param serializer: An object model serializer.
    :param deserializer: An object model deserializer.
    """

    models = models

    def __init__(self, client, config, serializer, deserializer) -> None:
        self._client = client
        self._serialize = serializer
        self._deserialize = deserializer
        self._config = config

    def list(
        self,
        **kwargs
    ) -> AsyncIterable["models.OperationListResult"]:
        """Gets a list of hybrid compute operations.

        :keyword callable cls: A custom type or function that will be passed the direct response
        :return: An iterator like instance of either OperationListResult or the result of cls(response)
        :rtype: ~azure.core.async_paging.AsyncItemPaged[~connected_machine.models.OperationListResult]
        :raises: ~azure.core.exceptions.HttpResponseError
        """
        cls = kwargs.pop('cls', None)  # type: ClsType["models.OperationListResult"]
        error_map = {404: ResourceNotFoundError, 409: ResourceExistsError}
        error_map.update(kwargs.pop('error_map', {}))
        api_version = "2020-08-02"

        def prepare_request(next_link=None):
            # Construct headers
            header_parameters = {}  # type: Dict[str, Any]
            header_parameters['Accept'] = 'application/json'

            if not next_link:
                # Construct URL
                url = self.list.metadata['url']  # type: ignore
                # Construct parameters
                query_parameters = {}  # type: Dict[str, Any]
                query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str')

                request = self._client.get(url, query_parameters, header_parameters)
            else:
                url = next_link
                query_parameters = {}  # type: Dict[str, Any]
                request = self._client.get(url, query_parameters, header_parameters)
            return request

        async def extract_data(pipeline_response):
            deserialized = self._deserialize('OperationListResult', pipeline_response)
            list_of_elem = deserialized.value
            if cls:
                list_of_elem = cls(list_of_elem)
            return None, AsyncList(list_of_elem)

        async def get_next(next_link=None):
            request = prepare_request(next_link)

            pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs)
            response = pipeline_response.http_response

            if response.status_code not in [200]:
                error = self._deserialize(models.ErrorResponse, response)
                map_error(status_code=response.status_code, response=response, error_map=error_map)
                raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)

            return pipeline_response

        return AsyncItemPaged(
            get_next, extract_data
        )
    list.metadata = {'url': '/providers/Microsoft.HybridCompute/operations'}  # type: ignore

{'repo_name': 'Azure/azure-cli-extensions', 'stars': '109', 'repo_language': 'Python', 'file_name': 'azure-cli-extensions.sln', 'mime_type': 'text/plain', 'hash': -2073268130822354541, 'source_dataset': 'data'}


/*
 * Apache 2.0 License
 *
 * Copyright (c) Sebastian Katzer 2017
 *
 * This file contains Original Code and/or Modifications of Original Code
 * as defined in and that are subject to the Apache License
 * Version 2.0 (the 'License'). You may not use this file except in
 * compliance with the License. Please obtain a copy of the License at
 * http://opensource.org/licenses/Apache-2.0/ and read it before using this
 * file.
 *
 * The Original Code and all software distributed under the License are
 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
 * Please see the License for the specific language governing rights and
 * limitations under the License.
 */

namespace LocalNotificationProxy.LocalNotification.Trigger
{
    using System;

    internal abstract class DateTrigger
    {
        /// <summary>
        /// Default unit is SECOND
        /// </summary>
        public enum Unit : byte
        {
            NULL, SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, QUARTER, YEAR
        }

        /// <summary>
        /// Gets or sets the occurrence counter.
        /// </summary>
        public int Occurrence { get; protected set; } = 1;

        /// <summary>
        /// Gets the next trigger date.
        /// </summary>
        /// <param name="date">The date from where to calculate the next one.</param>
        /// <returns>Null if there is no next trigger date.</returns>
        public abstract DateTime? GetNextTriggerDate(DateTime date);
    }
}

{'repo_name': 'katzer/cordova-plugin-local-notifications', 'stars': '2408', 'repo_language': 'Java', 'file_name': 'local-notification.js', 'mime_type': 'text/plain', 'hash': 8947847125109782448, 'source_dataset': 'data'}


# Local development services.
#
# To activate this feature, follow the instructions at the top of the
# 'example.settings.local.php' file, which sits next to this file.
parameters:
  http.response.debug_cacheability_headers: true
services:
  cache.backend.null:
    class: Drupal\Core\Cache\NullBackendFactory

{'repo_name': 'trendmicro/SecureCodingDojo', 'stars': '171', 'repo_language': 'PHP', 'file_name': 'blue_ch3.flag', 'mime_type': 'text/plain', 'hash': 6803615281236806637, 'source_dataset': 'data'}


! Gallium Arsenide: Tutorial Example 1

 num_wann    =  4
 num_iter    = 20

! SYSTEM

begin unit_cell_cart
bohr
-5.367  0.000  5.367
 0.000  5.367  5.367
-5.367  5.367  0.000
end unit_cell_cart

begin atoms_frac
Ga 0.00   0.00   0.00
As 0.25  0.25  0.25
end atoms_frac

begin projections
As:sp3
end projections

! KPOINTS

mp_grid : 2 2 2

begin kpoints
0.0 0.0 0.0
0.0 0.0 0.5
0.0 0.5 0.0
0.0 0.5 0.5
0.5 0.0 0.0
0.5 0.0 0.5
0.5 0.5 0.0
0.5 0.5 0.5
end kpoints

!We set this flag to read the bloch states from
!a formatted file. This is to ensure the example
!works on all platforms. The default (.false.) state
!should be used on production runs
wvfn_formatted=.true.

{'repo_name': 'wannier-developers/wannier90', 'stars': '104', 'repo_language': 'Fortran', 'file_name': 'overview.fig', 'mime_type': 'text/plain', 'hash': -8873230835825742530, 'source_dataset': 'data'}


create table parent (
a int not null,
b int not null,
c int not null,
primary key (a,b),
unique(b,c) using hash,
index(c,a)) engine = ndb;
create table child (
a int not null,
b int not null,
c int not null,
primary key (b,a),
unique(c,b) using hash,
index(c,a)) engine = ndb;
insert into parent values (1,2,3);
alter table child add constraint fkname foreign key (c,a) references parent(a,b) on delete restrict on update restrict;
insert into child values (2,1,2);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fkname` FOREIGN KEY (`c`,`a`) REFERENCES `parent` (`a`,`b`) ON DELETE RESTRICT ON UPDATE RESTRICT)
insert into child values (1,1,1);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fkname` FOREIGN KEY (`c`,`a`) REFERENCES `parent` (`a`,`b`) ON DELETE RESTRICT ON UPDATE RESTRICT)
insert into child values (2,1,1);
delete from parent;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fkname` FOREIGN KEY (`c`,`a`) REFERENCES `parent` (`a`,`b`) ON DELETE RESTRICT ON UPDATE RESTRICT)
delete from child;
alter table child drop foreign key fkname;
alter table child add constraint fkname foreign key (b,a) references parent(a,b) on delete restrict on update restrict;
insert into child values (1,2,2);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fkname` FOREIGN KEY (`b`,`a`) REFERENCES `parent` (`a`,`b`) ON DELETE RESTRICT ON UPDATE RESTRICT)
insert into child values (2,3,1);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fkname` FOREIGN KEY (`b`,`a`) REFERENCES `parent` (`a`,`b`) ON DELETE RESTRICT ON UPDATE RESTRICT)
insert into child values (2,1,1);
delete from parent;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fkname` FOREIGN KEY (`b`,`a`) REFERENCES `parent` (`a`,`b`) ON DELETE RESTRICT ON UPDATE RESTRICT)
delete from child;
alter table child drop foreign key fkname;
alter table child add constraint fkname foreign key (c,b) references parent(a,b) on delete restrict on update restrict;
insert into child values (1,2,2);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fkname` FOREIGN KEY (`c`,`b`) REFERENCES `parent` (`a`,`b`) ON DELETE RESTRICT ON UPDATE RESTRICT)
insert into child values (2,3,1);
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fkname` FOREIGN KEY (`c`,`b`) REFERENCES `parent` (`a`,`b`) ON DELETE RESTRICT ON UPDATE RESTRICT)
insert into child values (2,2,1);
delete from parent;
ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails (`test`.`child`, CONSTRAINT `fkname` FOREIGN KEY (`c`,`b`) REFERENCES `parent` (`a`,`b`) ON DELETE RESTRICT ON UPDATE RESTRICT)
drop table child, parent;
#
# Bug#21664899 : FAILURE CREATING COMPOSITE FKS REFERENCING COMPOSITE PKS OF PARENT
#
#create table t1
create table t1 (
a int not null,
b int not null,
c int not null,
primary key pk1(a,b)
) engine=ndbcluster;
#create t2 with a unique key on single column
create table t2 (
a int not null,
b int not null,
c int not null,
unique key uniquet2a(a),
constraint fkt2ab foreign key (a,b) references t1(a,b)
) engine=ndbcluster;
#verify the presence of uniquet2a, fkt2ab & and an extra key for fkt2ab
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int NOT NULL,
  `b` int NOT NULL,
  `c` int NOT NULL,
  UNIQUE KEY `uniquet2a` (`a`),
  KEY `fkt2ab` (`a`,`b`),
  CONSTRAINT `fkt2ab` FOREIGN KEY (`a`, `b`) REFERENCES `t1` (`a`, `b`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
alter table t2 drop key uniquet2a;
#alter add a unique constraint on single key
alter table t2 add constraint uniquet2a unique (a);
#verify the presence of uniquet2a, fkt2ab & and an extra key for fkt2ab
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int NOT NULL,
  `b` int NOT NULL,
  `c` int NOT NULL,
  UNIQUE KEY `uniquet2a` (`a`),
  KEY `fkt2ab` (`a`,`b`),
  CONSTRAINT `fkt2ab` FOREIGN KEY (`a`, `b`) REFERENCES `t1` (`a`, `b`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
#alter add a unique constraint on all cols in fk
alter table t2 add constraint uniquet2ab unique (a,b);
#verify the presence of uniquet2a, uniquet2ab, fkt2ab. no extra key for fkt2ab
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int NOT NULL,
  `b` int NOT NULL,
  `c` int NOT NULL,
  UNIQUE KEY `uniquet2a` (`a`),
  UNIQUE KEY `uniquet2ab` (`a`,`b`),
  CONSTRAINT `fkt2ab` FOREIGN KEY (`a`, `b`) REFERENCES `t1` (`a`, `b`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
#try adding fk(a,b,c) referring t1(a,b,c), it should fail without parent index.
alter table t2 add constraint fkt2abc foreign key (a,b,c) references t1(a,b,c);
ERROR HY000: Failed to add the foreign key constraint. Missing index for constraint 'fkt2abc' in the referenced table 't1'
#now add a unique key but on a different column order and try again
alter table t1 add constraint uniquet1abc unique (c,a,b);
alter table t2 add constraint fkt2abc foreign key (a,b,c) references t1(a,b,c);
#verify the presence of new fk
show create table t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `a` int NOT NULL,
  `b` int NOT NULL,
  `c` int NOT NULL,
  UNIQUE KEY `uniquet2a` (`a`),
  UNIQUE KEY `uniquet2ab` (`a`,`b`),
  KEY `fkt2abc` (`a`,`b`,`c`),
  CONSTRAINT `fkt2ab` FOREIGN KEY (`a`, `b`) REFERENCES `t1` (`a`, `b`),
  CONSTRAINT `fkt2abc` FOREIGN KEY (`a`, `b`, `c`) REFERENCES `t1` (`a`, `b`, `c`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
#cleanup
drop table t2, t1;

{'repo_name': 'mysql/mysql-server', 'stars': '5369', 'repo_language': 'C++', 'file_name': 'combinations', 'mime_type': 'text/plain', 'hash': 6145260980908629296, 'source_dataset': 'data'}


/* Expression parsing for plural form selection.
   Copyright (C) 2000-2001, 2003, 2005-2007 Free Software Foundation, Inc.
   Written by Ulrich Drepper <drepper@cygnus.com>, 2000.

   This program is free software; you can redistribute it and/or modify it
   under the terms of the GNU Library General Public License as published
   by the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
   USA.  */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include <ctype.h>
#include <stdlib.h>
#include <string.h>

#include "plural-exp.h"

#if (defined __GNUC__ && !(__APPLE_CC__ > 1) && !defined __cplusplus) \
    || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)

/* These structs are the constant expression for the germanic plural
   form determination.  It represents the expression  "n != 1".  */
static const struct expression plvar =
{
  .nargs = 0,
  .operation = var,
};
static const struct expression plone =
{
  .nargs = 0,
  .operation = num,
  .val =
  {
    .num = 1
  }
};
struct expression GERMANIC_PLURAL =
{
  .nargs = 2,
  .operation = not_equal,
  .val =
  {
    .args =
    {
      [0] = (struct expression *) &plvar,
      [1] = (struct expression *) &plone
    }
  }
};

# define INIT_GERMANIC_PLURAL()

#else

/* For compilers without support for ISO C 99 struct/union initializers:
   Initialization at run-time.  */

static struct expression plvar;
static struct expression plone;
struct expression GERMANIC_PLURAL;

static void
init_germanic_plural ()
{
  if (plone.val.num == 0)
    {
      plvar.nargs = 0;
      plvar.operation = var;

      plone.nargs = 0;
      plone.operation = num;
      plone.val.num = 1;

      GERMANIC_PLURAL.nargs = 2;
      GERMANIC_PLURAL.operation = not_equal;
      GERMANIC_PLURAL.val.args[0] = &plvar;
      GERMANIC_PLURAL.val.args[1] = &plone;
    }
}

# define INIT_GERMANIC_PLURAL() init_germanic_plural ()

#endif

void
internal_function
EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
			   const struct expression **pluralp,
			   unsigned long int *npluralsp)
{
  if (nullentry != NULL)
    {
      const char *plural;
      const char *nplurals;

      plural = strstr (nullentry, "plural=");
      nplurals = strstr (nullentry, "nplurals=");
      if (plural == NULL || nplurals == NULL)
	goto no_plural;
      else
	{
	  char *endp;
	  unsigned long int n;
	  struct parse_args args;

	  /* First get the number.  */
	  nplurals += 9;
	  while (*nplurals != '\0' && isspace ((unsigned char) *nplurals))
	    ++nplurals;
	  if (!(*nplurals >= '0' && *nplurals <= '9'))
	    goto no_plural;
#if defined HAVE_STRTOUL || defined _LIBC
	  n = strtoul (nplurals, &endp, 10);
#else
	  for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
	    n = n * 10 + (*endp - '0');
#endif
	  if (nplurals == endp)
	    goto no_plural;
	  *npluralsp = n;

	  /* Due to the restrictions bison imposes onto the interface of the
	     scanner function we have to put the input string and the result
	     passed up from the parser into the same structure which address
	     is passed down to the parser.  */
	  plural += 7;
	  args.cp = plural;
	  if (PLURAL_PARSE (&args) != 0)
	    goto no_plural;
	  *pluralp = args.res;
	}
    }
  else
    {
      /* By default we are using the Germanic form: singular form only
         for `one', the plural form otherwise.  Yes, this is also what
         English is using since English is a Germanic language.  */
    no_plural:
      INIT_GERMANIC_PLURAL ();
      *pluralp = &GERMANIC_PLURAL;
      *npluralsp = 2;
    }
}

{'repo_name': 'Provenance-Emu/Provenance', 'stars': '4257', 'repo_language': 'C', 'file_name': 'libretro.c', 'mime_type': 'text/x-c', 'hash': 2900266232275877961, 'source_dataset': 'data'}


/**
 * @object Math Augmentation
 * @author Matthew Wagerfield
 */
Math.PIM2 = Math.PI*2;
Math.PID2 = Math.PI/2;
Math.randomInRange = function(min, max) {
  return min + (max - min) * Math.random();
};
Math.clamp = function(value, min, max) {
  value = Math.max(value, min);
  value = Math.min(value, max);
  return value;
};

{'repo_name': 'msurguy/triangles', 'stars': '669', 'repo_language': 'JavaScript', 'file_name': 'triangles.js', 'mime_type': 'text/plain', 'hash': 1744092727908206109, 'source_dataset': 'data'}


; RUN: llc < %s -mtriple=arm-apple-darwin -relocation-model=pic -mattr=+v6,+vfp2

@"\01LC" = external constant [15 x i8]		; <[15 x i8]*> [#uses=1]

declare i32 @printf(i8* nocapture, ...) nounwind

define i32 @main() nounwind {
entry:
	br label %bb.i1.i

bb.i1.i:		; preds = %Cos.exit.i.i, %entry
	br label %bb.i.i.i

bb.i.i.i:		; preds = %bb.i.i.i, %bb.i1.i
	br i1 undef, label %Cos.exit.i.i, label %bb.i.i.i

Cos.exit.i.i:		; preds = %bb.i.i.i
	br i1 undef, label %bb2.i.i, label %bb.i1.i

bb2.i.i:		; preds = %Cos.exit.i.i
	br label %bb3.i.i

bb3.i.i:		; preds = %bb5.i.i, %bb2.i.i
	br label %bb4.i.i

bb4.i.i:		; preds = %bb4.i.i, %bb3.i.i
	br i1 undef, label %bb5.i.i, label %bb4.i.i

bb5.i.i:		; preds = %bb4.i.i
	br i1 undef, label %bb.i, label %bb3.i.i

bb.i:		; preds = %bb.i, %bb5.i.i
	br i1 undef, label %bb1.outer2.i.i.outer, label %bb.i

bb1.outer2.i.i.outer:		; preds = %Fft.exit.i, %bb5.i12.i, %bb.i
	br label %bb1.outer2.i.i

bb1.outer2.i.i:		; preds = %bb2.i9.i, %bb1.outer2.i.i.outer
	br label %bb1.i.i

bb1.i.i:		; preds = %bb1.i.i, %bb1.outer2.i.i
	br i1 undef, label %bb2.i9.i, label %bb1.i.i

bb2.i9.i:		; preds = %bb1.i.i
	br i1 undef, label %bb4.i11.i, label %bb1.outer2.i.i

bb4.i11.i:		; preds = %bb4.i11.i, %bb2.i9.i
	br i1 undef, label %bb5.i12.i, label %bb4.i11.i

bb5.i12.i:		; preds = %bb4.i11.i
	br i1 undef, label %bb7.i.i, label %bb1.outer2.i.i.outer

bb7.i.i:		; preds = %bb7.i.i, %bb5.i12.i
	br i1 undef, label %Fft.exit.i, label %bb7.i.i

Fft.exit.i:		; preds = %bb7.i.i
	br i1 undef, label %bb5.i, label %bb1.outer2.i.i.outer

bb5.i:		; preds = %Fft.exit.i
	%0 = tail call i32 (i8*, ...)* @printf(i8* getelementptr ([15 x i8]* @"\01LC", i32 0, i32 0), double undef, double undef) nounwind		; <i32> [#uses=0]
	unreachable
}

{'repo_name': 'KhronosGroup/SPIRV-LLVM', 'stars': '264', 'repo_language': 'C++', 'file_name': 'CMakeLists.txt', 'mime_type': 'text/plain', 'hash': 6209170641826447950, 'source_dataset': 'data'}


// Globale Variablen
var iVer, iSec, iKnights, iScouts, iPatrol1, iPatrol2, iFood, iAdd, iScout, iInterval, iCount, iPosition, iAttack: Integer;

// Schlussnachricht an die Spieler
procedure OnPlayerVictory(iIndex: Integer);
begin
	Actions.OverlayTextSet(iIndex, '<$3>');
end;

procedure OnTick;
begin
  // Verbündeten setzen, Karte aufdecken
  if States.GameTime = 200 then begin
	Actions.PlayerAllianceChange(0, 7, true, true);

	Actions.FogRevealCircle(0, 127, 23, 5);
	Actions.FogRevealCircle(0, 122, 23, 5);
	Actions.FogRevealCircle(0, 116, 19, 5);
	Actions.FogRevealCircle(0, 138, 61, 5);
	Actions.FogRevealCircle(0, 147, 55, 10);
	Actions.FogRevealCircle(0, 133, 56, 10);
	Actions.FogRevealCircle(0, 158, 48, 10);
	Actions.FogRevealCircle(0, 147, 40, 10);

  end;

  // Verstärkung aus dem Bildschirmrand
  if States.GameTime = iVer then
  begin
    iKnights := Actions.GiveGroup(3, 22, 191, 25, 6, 3, 3);
    Actions.GroupOrderWalk(iKnights, 180, 25, 6);
	iScouts := Actions.GiveGroup(3, 21, 191, 30, 6, 3, 3);
	Actions.GroupOrderWalk(iScouts, 180, 30, 6);
  end;
  for iSec := 1 to 6 do
    if States.GameTime = iVer + (iSec * 15) then
    begin
      iAdd := Actions.GiveGroup(3, 22, 191, 25, 6, 3, 3);
      Actions.GroupOrderLink(iAdd, iKnights);

	  iAdd := Actions.GiveGroup(3, 21, 191, 30, 6, 3, 3);
      Actions.GroupOrderLink(iAdd, iScouts);
    end;

  // Nachrichten
  if States.GameTime = 9000 then
	begin
		Actions.ShowMsg(0, '<$0>');
		Actions.GroupOrderHalt(iPatrol1);
		Actions.GroupOrderHalt(iPatrol2);
		Actions.GroupOrderFood(iPatrol1);
		Actions.GroupOrderFood(iPatrol2);
	end;
  if States.GameTime = 31800 then
  begin
	Actions.ShowMsg(0, '<$1>');
  end;

  // Reiter
  if ((States.GroupDead(iPatrol1) = false) OR (States.GroupDead(iPatrol2) = false))
	AND (States.GameTime = iCount + iInterval)
  then begin
	if iPosition = 0 then
	begin
		Actions.GroupOrderWalk(iPatrol1, 76, 37, 2);
		Actions.GroupOrderWalk(iPatrol2, 77, 33, 3);
		iCount := iCount + 400;
	end;
	if iPosition = 1 then
	begin
		iCount := iCount + 30;
		Actions.GroupOrderWalk(iPatrol1, 103, 42, 5);
		Actions.GroupOrderWalk(iPatrol2, 110, 39, 2);
	end;
	if iPosition = 2 then
	begin
		iCount := iCount - 320;
		Actions.GroupOrderWalk(iPatrol1, 97, 53, 4);
		Actions.GroupOrderWalk(iPatrol2, 122, 37, 2);
	end;
	if iPosition = 3 then
	begin
		iCount := iCount - 290;
		Actions.GroupOrderWalk(iPatrol1, 115, 67, 2);
		Actions.GroupOrderWalk(iPatrol2, 141, 33, 2);
	end;
	if iPosition = 4 then
	begin
		iCount := iCount - 200;
		Actions.GroupOrderWalk(iPatrol1, 94, 70, 5);
		Actions.GroupOrderWalk(iPatrol2, 152, 34, 1);

	end;
	if iPosition = 5 then
	begin
		Actions.GroupOrderWalk(iPatrol1, 15, 61, 2);
		Actions.GroupOrderWalk(iPatrol2, 115, 68, 5);
	end;
	if iPosition = 6 then
	begin
		Actions.GroupOrderWalk(iPatrol1, 15, 61, 2);
		Actions.GroupOrderWalk(iPatrol2, 11, 61, 2);
		iCount := iCount + 600;
	end;
	if iPosition = 7 then
	begin
		iFood := iFood + 1;
		if iFood = 5 then
		begin
			Actions.GroupOrderHalt(iPatrol1);
			Actions.GroupOrderHalt(iPatrol2);
			Actions.GroupOrderFood(iPatrol1);
			Actions.GroupOrderFood(iPatrol2);
			iInterval := iPatrol1;
			iPatrol1 := iPatrol2;
			iPatrol2 := iInterval;
			iInterval := 400;
			iCount := iCount + 600;
			iFood := 0;
		end;
	end;

	// Aufzählen
	iCount := iCount + iInterval;
	iPosition := iPosition + 1;
	if iPosition = 8 then
	begin iPosition := 0; end;

  end else if States.GameTime = iCount + iInterval then
  begin
	if iAttack = 0 then
	begin
		// Verzögerung um 2 Minuten
		iCount := iCount + 1000;
	end;
	if iAttack = 1 then
	begin
		// Verstärkung
		Actions.ShowMsg(0, '<$2>');
		iVer := States.GameTime + 10;
		iCount := iCount + 1000;
	end;
	if iAttack = 2 then
	begin
		// Barbaren Angriff
		Actions.GiveGroup(1, 23, 31, 37, 3, 45, 5);
		iCount := iCount + 1200;
	end;
	iAttack := iAttack + 1;
  end;

end;

procedure OnMissionStart;
begin
  // Patrolierende Reiter
  iPatrol1 := Actions.GiveGroup(1, 27, 15, 61, 2, 5, 3);
  iAdd := Actions.GiveGroup(1, 21, 14, 60, 2, 4, 3);
  Actions.GroupOrderLink(iAdd, iPatrol1);

  iPatrol2 := Actions.GiveGroup(1, 22, 11, 61, 2, 5, 3);
  iAdd := Actions.GiveGroup(1, 21, 9, 61, 2, 4, 3);
  Actions.GroupOrderLink(iAdd, iPatrol2);

  Actions.GroupOrderFood(iPatrol1);
  Actions.GroupOrderFood(iPatrol2);

  iCount := 12000;
  iPosition := 0;
  iInterval := 400;
  iAttack := 0;
  iFood := 0;
  iVer := -1000;
  iScout := -1;

  // Häuser reparieren
  Actions.HouseRepairEnable(States.HouseAt(160, 58), true);
  Actions.HouseRepairEnable(States.HouseAt(158, 62), true);
  Actions.HouseRepairEnable(States.HouseAt(164, 63), true);
  Actions.HouseRepairEnable(States.HouseAt(168, 66), true);
  Actions.HouseRepairEnable(States.HouseAt(164, 67), true);
  Actions.HouseRepairEnable(States.HouseAt(171, 69), true);
  Actions.HouseRepairEnable(States.HouseAt(170, 74), true);
  Actions.HouseRepairEnable(States.HouseAt(156, 78), true);
  // Waren
  Actions.HouseAddWaresTo(States.HouseAt(171, 69), 8, 3);
  Actions.HouseAddWaresTo(States.HouseAt(171, 69), 10, 2);
  Actions.HouseAddWaresTo(States.HouseAt(171, 69), 13, 1);
  Actions.HouseAddWaresTo(States.HouseAt(171, 69), 27, 4);
  Actions.HouseAddWaresTo(States.HouseAt(124, 66), 27, 4);
  // Block
  Actions.HouseDeliveryBlock(States.HouseAt(15, 53), true);

end;

{'repo_name': 'Kromster80/kam_remake', 'stars': '265', 'repo_language': 'Pascal', 'file_name': 'text.tur.libx', 'mime_type': 'text/plain', 'hash': 607813993337973662, 'source_dataset': 'data'}